Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
66 views

Computer Assignment 10

Comp ass

Uploaded by

nikunjarora2008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Computer Assignment 10

Comp ass

Uploaded by

nikunjarora2008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computer Assignment

1.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

>= 300 Science and Computer

>= 200 and < 300 Commerce and Computer

>= 75 and < 200 Arts and Animation

< 75 Try Again

void print() – Display student name, age, mks and stream allocated.

Call all the above methods in main method using an object.

2. 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.

3. Design a class name ShowRoom with the following description:

Instance variables / Data members:


String name — To store the name of the customer
long mobno — To store the mobile number of the customer
double cost — To store the cost of the items purchased
double dis — To store the discount amount
double amount — To store the amount to be paid after discount

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)

Less than or equal to ₹10000 5%

More than ₹10000 and less than or equal to


10%
₹20000

More than ₹20000 and less than or equal to


15%
₹35000

More than ₹35000 20%

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

(b) Display the following pattern using iteration (looping) statement:

1
12
123
1234
12345

5. 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) v9oid 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

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:

Consider the number 3025


Square of sum of the halves of 3025 = (30 + 25)2
= (o55)2
= 3025 is a tech number.

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.)

Example: consider the number 1124.


Sum of the digits = 1 + 1 + 2 + 4 = 8
Poroduct of the digits = 1 x 1 x 2 x 4 = 8

9. Using switch statement, write a menu driven program for the following:

1. To find and display the sum of the series given below:


S = x1 - x2 + x3 - x4 + x5 .......... - x20
(where x = 2)
2. To display the following series:
1 11 111 1111 11111

For an incorrect option, an appropriate error message should be displayed.

10. Design a class to overload a function sumSeries() as follows:

(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:

s=1/x−2/x+3/x−4/x+5/x... ... ... to n terms

(ii) void sumSeries(): to find and display the sum of the following series:

s=1+(1×2)+(1×2×3)+... ... ... +(1×2×3×4... ... ... ×20)

You might also like