0% found this document useful (0 votes)
24 views4 pages

Class X

The document outlines a series of programming tasks, including defining classes for students and movies, implementing methods for calculating averages and factorials, and creating menu-driven programs for various mathematical checks. It covers concepts such as class design, method overloading, and user input handling. Additionally, it includes examples of special numbers, pronic numbers, and generating patterns and Unicode values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Class X

The document outlines a series of programming tasks, including defining classes for students and movies, implementing methods for calculating averages and factorials, and creating menu-driven programs for various mathematical checks. It covers concepts such as class design, method overloading, and user input handling. Additionally, it includes examples of special numbers, pronic numbers, and generating patterns and Unicode values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Question 4:

Define a class Student as given below:

Data members/instance variables:


name, age, m1, m2, m3 (marks in 3 subjects), maximum, average

Member methods:

1. A parameterized constructor to initialize the data members.


2. To accept the details of a student.
3. To compute the average and the maximum out of three marks.
4. To display the name, age, marks in three subjects, maximum and
average.

Write a main method to create an object of a class and call the above member
methods.

Question 5:

Write a program to input a number and print whether the number is a special
number or not.

(A number is said to be a special number, if the sum of the factorial of the


digits of the number is same as the original number).

Example:
145 is a special number, because 1! + 4! + 5! = 1 + 24 + 120 = 145.
(Where ! stands for factorial of the number and the factorial value of a number
is the product of all integers from 1 to that number,
example 5! = 1 * 2 * 3 * 4 * 5 = 120)

Question 6:

Design a class to overload a function polygon() as follows:

1. void polygon(int n, char ch) — with one integer and one character type
argument to draw a filled square of side n using the character stored in
ch.

2. void polygon(int x, int y) — with two integer arguments that draws a


filled rectangle of length x and breadth y, using the symbol '@'.

3. void polygon() — with no argument that draws a filled triangle shown


below:
Example:

1. Input value of n=2, ch = 'O'


Output:
OO
OO

2. Input value of x = 2, y = 5
Output:
@@@@@
@@@@@

3. Output:
*
**
***

Question 7:

Define a class named movieMagic with the following description:

Data Members Purpose

int year To store the year of release of a movie

String title To store the title of the movie

To store the popularity rating of the movie


float rating
(minimum rating=0.0 and maximum rating=5.0)

Member
Purpose
Methods

Default constructor to initialize numeric data members to 0


movieMagic()
and String data member to "".

void accept() To input and store year, title and rating

void To display the title of the movie and a message based on the
Member
Purpose
Methods

display() rating as per the table given below

Ratings Table

Rating Message to be displayed

0.0 to 2.0 Flop

2.1 to 3.4 Semi-Hit

3.5 to 4.4 Hit

4.5 to 5.0 Super-Hit

Write a main method to create an object of the class and call the above
member methods.

Question 8:

Using switch statement, write a menu driven program to:


(i) To find and display all the factors of a number input by the user ( including
1 and the excluding the number itself).
Example:
Sample Input : n = 15
Sample Output : 1, 3, 5

(ii) To find and display the factorial of a number input by the user (the factorial
of a non-negative integer n, denoted by n!, is the product of all integers less
than or equal to n.)
Example:
Sample Input : n = 5
Sample Output : 5! = 1*2*3*4*5 = 120

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


Question 9:

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

Question 10:

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

You might also like