Computer Assignment List
Assignment no. Assignment Questions
1. Write a program to check if a given number is Palindrome.
2. Define a class employee having the following description:
Instance Variable:
Int pan - to store pan no.
String name - to store name
Double tax_income - to store taxable income
Double tax - to store calculated tax
Member functions:
input() - store pan no, name, taxable
calc() - calculate tax for employee
display() - output details of employee
Write a program to compute tax according to given conditions
Upto 1,00,000 - No tax
From 1,00,001 to 1,50,000 - 10% of income exceeding 1,00,000
From 1,50,001 to 2,50,000 - 5000 + 20% of income exceeding
1,50,000
Above 2,50,000 - 25000 + 30% of income exceeding 2,50,000
3 Define a class called Mobike with the following description:
Instance Variables/Data Members:
bno : to store the bike’s number
phno : to store the phone number of the customer
name : to store the name of the customer
days : to store the number of days the bike is taken on rent
charge : to calculate and store the rental charge
Member Methods:
void input() : to input and store the detail of the customer
void compute(): to compute the rental charge. The rent for a Mobike
is charged on the following basis.
First five days : 500 per day
Next five days : 400 per day
Rest of the days : 200 per day
void display : to display the details in the following format:
Bike No. Phone No. Name No. Of Days Charge
_______ __________ _______ ____________ ________
4 Write a program with the following description:
Class name: Student
Data Members:
name : to store the name of a student
hindi : To store the marks in hindi subject
english : To store the marks in english subject
maths : To store the marks in maths subject
computer : To store the marks in computer subject
average : To store the average of the marks obtained
grade : To store the grade depending upon the average
Member Methods:
void accept() : To accept name and marks in 4 subjects
void calcavg() : To calculate and store the grade according to the
following slabs:
Average Marks Grade Obtained
90 and above A++
Between 75 to 89 (both inclusive) A
Between 60 to 75 (both inclusive) B
Less than 60 C
5 Define a class called FruitJuice with the following description:
Instance Variable/Data Members:
int product_code - stores the product code number
String flavour - stores flavour of the juice (orange, apple, etc)
String pack_type - stores the type of packaging (tetra-pack, bottle,
etc)
int product_price - stores the price of the product
Member Methods:
void input() - to input and store the product code, flavour, pack type,
pack size and product price
void discount() - to reduce the product code by 10
void display() - to display the product code, flavor, pack type, pack
size and product price
Write the main method to create an object of the class and call the
above member methods.
6 Define a class called Library with the following description:
Instance Variables/Data Members:
int acc_num - stores the accession number of the book
String title - stores the title of the book
String author - stores the name of the author
Member Methods:
void input() - To input and store the accession number, title and
author.
void compute() - To accept the number of days late, calculate and
display and fine charged at the rate of Rs. 2 per day.
void display() - To display the details in the following in the following
format:
Accession Number Title Author
Write a main method to create an object of the class and call the
above member methods.
7 Design a class to overload a function volume() as follows:
(i) double volume (double r) - with radius ‘r’ as an argument, returns
3
the volume of sphere using the formula: v = 4/3 x 22/7 x 𝑟
(ii) double volume (double h, double r) - with height ‘h’ and radius ‘r’
as the arguments, double volume of a cylinder using the formula:
2
v = 22/7 x 𝑟 x h
(iii) double volume (double l, double b, double h) - with length ‘l’,
breadth ‘b’ and height ‘h’ as the arguments, returns the volume of a
cuboid using the formula: v = l x b x h
8 Design a class to overload a function area() as follows:
(i) double area (double a, double b, double c) with three double
arguments, returns the area of a scalene triangle using the formula:
area = √(s(s - a)(s - b)(s - c)) where s = (a + b + c)/2
(ii) double area (int a, int b, int height) with three arguments, returns
the area of a trapezium using the formula: area = ½ x height x (a+b)
(iii) double area (double diagonal1, double diagonal2) with two
double arguments, returns the area of a rhombus using the formula:
area = ½ x (diagonal1 x diagonal2)