Computer Assignment 10
Computer Assignment 10
Member variables:
name — name of student
age — age of student
mks — marks obtained
stream — stream allocated
Member methods:
void accept() — Accept name, age and marks using methods of Scanner class.
void allocation() — Allocate the stream as per following criteria:
Mks stream
void print() – Display student name, age, mks and stream allocated.
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
void print(int n) - To check whether the number is a lead number. A lead number is the
one whose sum of even digits are equal to sum of odd digits.
e.g. 3669
odd digits sum = 3 + 9 = 12
even digits sum = 6 + 6 = 12
3669 is a lead number.
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
Discount (in
Cost
percentage)
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.
4. Using the switch-case statement, write a menu driven program to do the following:
(a) To generate and print Letters from A to Z and their Unicode
Letters Unicode
A 65
B 66
. .
. .
. .
Z 90
1
12
123
1234
12345
(a) void series (int x, int n) – To display the sum of the series given below:
x1 + x2 + x3 + .......... xn terms
(c) void series () – To display the sum of the series given below:
6. A tech number has even number of digits. If the number is split in two equal halves,
then the square of sum of these halves is equal to the number itself. Write a program to
generate and print all four digits tech numbers.
Example:
7. Write a program to input a number and check and print whether it is a Pronic number
or not. (Pronic number is the number which is the product of two consecutive integers)
Examples:
12 = 3 x 4
20 = 4 x 5
42 = 6 x 7
8. Write a program to accept a number and check and display whether it is a spy number
or not. (A number is spy if the sum of its digits equals the product of its digits.)
9. Using switch statement, write a menu driven program for the following:
(i) void sumSeries(int n, double x): with one integer argument and one double argument to
find and display the sum of the series given below:
(ii) void sumSeries(): to find and display the sum of the following series: