Question 1
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
Question 2
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=3, ch=’0’
Output:
0000
0000
0000
2. Input value of x = 3, y =5 Output:
@@@@@
@@@@@
. @@@@@
3. Output: *
**
***
Question 3
Write a program to initialize an array of 5 names and initialize another array
with their respective telephone numbers. Search for a name input by the
user, in the list. If found, display "Search Successful" and print the name
along with the telephone number, otherwise display "Search unsuccessful.
Name not enlisted".
Question 4:
Define a class called ParkingLot with the following description:
Instance variables/data members:
int vno — To store the vehicle number.
int hours — To store the number of hours the vehicle is parked in
the parking lot.
double bill — To store the bill amount.
Member Methods:
void input() — To input and store the vno and hours.
void calculate() — To compute the parking charge at the rate of ₹3
for the first hour or part thereof, and ₹1.50 for each additional hour
or part thereof.
void display() — To display the detail.
Write a main() method to create an object of the class and call the
above methods.
Question 5
Question 6
Question 7
Write a program to accept name and total marks of N number of
students in two single subscript array name[] and totalmarks[].
Calculate and print:
1. The average of the total marks obtained by N number of
students.
[average = (sum of total marks of all the students)/N]
2. Deviation of each student’s total marks with the average.
[deviation = total marks of a student – average]
Question 8
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 9
Design a class RailwayTicket with following description:
Instance variables/data members:
String name — To store the name of the customer
String coach — To store the type of coach customer wants to travel
long mobno — To store customer’s mobile number
int amt — To store basic amount of ticket
int totalamt — To store the amount to be paid after updating the
original amount
Member methods:
void accept() — To take input for name, coach, mobile number and
amount.
void update() — To update the amount as per the coach selected
(extra amount to be added in the amount as follows)
Type of Coaches Amount
First_AC 700
Second_AC 500
Third_AC 250
sleeper None
void display() — To display all details of a customer such as name,
coach, total amount and mobile number.
Write a main method to create an object of the class and call the
above member methods.
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
. .
. .
Letters Unicode
. .
Z 90
(b) Display the following pattern using iteration (looping)
statement:
1
1 2
1 23
1 234
1 2345