Grade 10 Computer Worksheet-DF.1732359404
Grade 10 Computer Worksheet-DF.1732359404
Price Discount
void display(): To display the name of the item and the net amount to be paid.
Write the main method to create an object and call the above methods.
2) Define a class to overload the method display as follows:
void display( ): To print the following format using nested loop
1
12
123
1234
12345
void display(int n): To print the square root of each digit of the given number.
Example:
n = 4329
Output – 3.0
1.414213562
1.732050808
2.0
Q.3) Design a class with the following specifications:
Class name: Student
Member variables:
name — name of student
age — age of student
mks — marks obtained
stream — stream allocated
(Declare the variables using appropriate data types)
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.
Call all the above methods in main method using an object.
Q.4) Define a class to overload the function print as follows:
void print() - to print the following format
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.