Computer_Assignment - Part I
Computer_Assignment - Part I
Programming Assignments
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Guidelines for Assignments
Print out of source code should be pasted on ruled side of Oxford file pages.
Print out of output should be pasted on white side of Oxford file pages.
Variable Description Table for each program should be written after the
source code.
Question sheet of each assignment should be pasted before each source code.
File should be covered with proper covering and must paste Computer or Java
CD is not required.
Part I:
Assignment 1:
Write a menu driven program to calculate maturity amount of a Bank Deposit.
The user is given the following options:
(i) Term Deposit
(ii) Recurring Deposit
For option (i), accept the principal (P), rate of interest (r) and the time period in years (n).
Calculate and print the maturity amount (A) receivable using the formula:
A = P [1+ r/100]
For option (ii), accept the monthly installment (P), rate of interest (r), and the time period in
months (n). Calculate and print the maturity amount (A) receivable using the formula:
A = P × n + P × n (n+1) × r/100 × 2 × 12
For an incorrect option, an appropriate error message should be displayed.
INPUT
User Menu
1. Term Deposit
2. Recurring Deposit
Enter your choice: 1
Enter the Principal: 1000
Enter the Rate of Interest: 7.25
Enter the time Period in Years: 2
OUTPUT
Maturity Value: 1150.25625
INPUT
User Menu
1. Term Deposit
2. Recurring Deposit
Enter your choice: 3
OUTPUT
Wrong Choice
Assignment 2:
A company announces an increment of their employees on the seniority basis (length of service) as
per the given tariff:
Length of service Increment Dearness Allowance
Up to 10 years 20% of basic 10% of basic
Above 10 and up to 20 years 25% of basic 15% of basic
Above 20 years 30% of basic 20% of basic
Write a program to find new basic by using the following class specifications:
Class : Increment
Data members/Instance variables:
String name : name of the employee
double basic : basic pay of the employee
int pds : length of service of the employee
Member methods :
void getdata(String n, int p, : to accept name, length of service, basic
double bs, double d) and DA
void calculate( ) : to find increment and update basic salary.
void display ( ) : to display length of service and update basic salary in
the format given below:
Output:
Name Length of service Basic Salary DA
****** *********** ********* *********
****** *********** ********* *********
****** *********** ********* *********
INPUT
Name: Ashish Kumar Shaw
Enter the basic pay: 15000.0
Enter the length of service: 12
OUTPUT
Name Length of Service Basic Salary DA
Ashish Kumar 12 15000.0 2250.0
Shaw
Assignment 3:
Given below is a hypothetical table showing rate of income tax from male citizens below the age of
65 year:
INPUT
Enter the age of a person: 60
Wrong Choice
Assignment 4:
Define a class called ‘Mobike’ with the following specifications:
Instance variable/ Data members:
int bno : to store the bike number
int phno : to store the phone number of the customer
String name : to store the name of the customer
int days : to store the number of days the bike is taken out on rent
int charge : to calculate and store the rental charge
Member methods :
void input ( ) : to input and store the details of the customer
void compute ( ) : to compute the rental charge
The rent for a mobike is charged on the following basis:
For first five days : Rs. 500 per day
For the next five days : Rs. 400 per day
Rest of the days : Rs. 200 per day
void display ( ) : to display the details in the following format:
Bike No. Phone No. Name No. of days Charge
***** ****** **** ******** ****
INPUT
Enter the name of the customer : Devjit Mandal
Enter the mobile number : 9804926607
OUTPUT
Bike No. Phone No. Name No. of days Charge
7432 9804926607 Devjit Mandal 18 6100
Assignment 5
A paper roll manufacturing company offers discount to the dealer and retailer based on the length of the
paper roll as per the following criteria:
Length of the paper Dealer Retailer
Up to 10 metres 10% 8%
11 metres and up to 20 metres 15% 10%
More than 20 metres 20% 15%
Write a program to input the length of paper roll and the amount of purchase. Use menu driven approach
having choices (D) for dealer and (R) for retailer to find and print the amount to be paid to the company after
discount.
For an inappropriate choice, display “Wrong Choice”.
INPUT
User Menu
1. D for Dealer
2. R for Retailer
Enter your Choice: D
Enter the length of the paper roll: 17
Enter the amount of purchase: 7500
OUTPUT
Amount to be paid: Rs. 6375
INPUT
User Menu
1. D for Dealer
2. R for Retailer
Enter your Choice: C
OUTPUT
Wrong Choice