Java Assignment Sheet 1
Java Assignment Sheet 1
Write a program to input the name and ticket amount for the customer and calculate
the discount amount and net amount to be paid. Display the output in the following
format for each customer:
(Assume that there are 15 customers, first customer is given the serial no (SI.
No.) 1, next customer 2 …….. and so on)
4. Write a menu driven program to accept a number from the user and check
whether it is a Prime number or an Automorphic number.
(a) Prime number: (A number is said to be prime, if it is only divisible by 1 and
itself)
Example: 3,5,7,11
(b) Automorphic number: (Automorphic number is the number which is contained in the
last digit(s) of its square.)
Example: 25 is an Automorphic number as its square is 625 and 25 is present as the
last two digits.
5. Design a class name ShowRoom with the following description:
Member methods:
ShowRoom() — default constructor to initialize data members
void input() — To input customer name, mobile number, cost
void calculate() — To calculate discount on the cost of purchased items, based on
following criteria
void display () — To display customer name, mobile number, amount to be paid after
discount.
Write a main method to create an object of the class and call the above member
methods.
6. Design a class to overload a function series( ) as follows:
(a) void series (int x, int n) – To display the sum of the series given below:
x1 + x2 + x3 + .......... xn terms
(b) void series (int p) – To display the following series:
0, 7, 26, 63 .......... p terms
(c) void series () – To display the sum of the series given below:
1/2 + 1/3 + 1/4 + .......... 1/10
Letters Unicode
A 65
B 66
. .
Z 90
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5