Professional Documents
Culture Documents
Category Tariff
Semi Deluxe Room Rs. 2,500/- per day
Deluxe Room Rs. 3,500/- per day
Super Deluxe Room Rs. 5,000/- per day
(iii) void display ()- display the details in different lines.
Write a main() to create an object and call the functions.
4. Define a class Library having the following description
Data Members/Instance Variables:
String name – user name int days- days book returned late
double fine – fine amount
Member functions/methods:
(i) default constructor to initialize the data members to default values
(ii) void accept()- to accept details for name and days
(iii) void calc()-calculate the fine amount as given below:
Number of days Fine
First 5 days 40 paise per day
Next five days 65 paise per day
Above 10 days 80 paise per day
(iv) void output() – display the details in a tabular format.
Write a main() to create an object and call the functions.
5. Define a class Sales_Purchase having the following description:
Data Members/Instance Vriables:
int price- showroom price of the car. String name – User Name
int n- number of years the car used.
double dep_Value – depreciated value.
Member Functions/methods:
void input() – to accept values for name, price and n
void calculate()- calculate the depreciated values as per
Number of years Rate of depreciation
1 10%
2 20%
3 30%
4 50%
Above 4 years 65%
Write a main() to create an object and call the functions.
6. Design a class to overload the function Pattern() as follows:
(i) void Pattern(int n)- To create the following pattern based on n value.
For Example if n is 5, then output is
1 3 5 7 9
3 5 7 9 11
5 7 9 11 13
7 9 11 13 15
9 11 13 15 17
(ii) void Pattern(String s) – To create the followed based on the word.
For Example: If s is "CYCLE"
Output: CYCLE
YCLE
CLE
LE
E
Write a main() method to create an object and call the functions.
7. Design a class to overload the function Series () as follows:
(i) void Series(int n) – to display the given series upto n terms.
For Example: If n is 5, then Output is 0, 3, 8, 15, 24
(ii) double Series()- calculates and returns the sum of the given series:
1 3 5 7 9
Sum= − + − +
2 4 6 8 10
Write a main() method to create an object and call the functions.
8. Design a class to overload the function Manipulate() as follows:
(i) String Manipulate(String s)- return a new string after converting the first and the last
character to uppercase.
(ii) String Manipulate(String s, char c)- returns a new string after removing the character c
present in the string.
9. Design a class to overload the constructor function Calc as follows:
(i) public calc() – calculates and displays the sum of integers in the range -10 to -20
(ii) public calc(int a[])- calculates and displays the sum and product of all the elements
present in the array a[].
Write a main() to invoke the above constructors.
10. Design a class to overload the function Split() as follows:
(i) void Split(int x)- if x is two-digit then display the digits of x with space between.
Example: If x is 12, then Output: 1 2
(ii) void Split(String x)- If x length is even, then split the string into two equal halves and
display.
Example: If x is "SING" then output is SI NG
(ii) void Split(double x)- Split and display the integer and real part.
Example: If x is 1.23 then output is 1 23
11. Using switch statement write a menu driven program to.
1. Pattern 1
2. Pattern 2
Display appropriate error message of the choice is invalid.
Pattern1 Pattern2
EGAMI 54321
GAMI 4321
AMI 321
MI 21
I 1
12. Using switch statement. Write a menu driven program to
1. Series1
2. Series2
Display appropriate error message of the choice is invalid.
1+3 2+5 8+15
Series1: + + ⋯…………..
1×3 2×5 8×15
1 1 1 1 1 1 1 1
Series2: + ( + ) + ( + + ) + ( + ⋯ … … … . )
1 1 2 1 2 3 1 10
13. Using switch statement. Write a menu driven program to
1. To check the input number is a perfect cube.
[A number is called perfect cube, if the product of its cube root value is equal to the
input]
Example: 27 is perfect cube. Cube root of 27 is 3, where 3 x 3 x 3=27
2. To check the input number’s ending digit is divisible by 3.
Display appropriate error message of the choice is invalid.
14. Using switch statement. Write a menu driven program to
1. Display special characters from the input string.
2. Display the string in the given format:
If String is JAVA
JAVA
AVAJ
VAJA
AJAV
Display appropriate error message of the choice is invalid.
15. Using switch statement write a menu driven program to.
1. Pattern 1
2. Pattern 2
Display appropriate error message of the choice is invalid.
Pattern1 Pattern2
A* 1
A*B* 01
A*B*C* 101
A*B*C*D* 0101
A*B*C*D*E* 10101
Display appropriate error message of the choice is invalid.
16. Write a Program to input a string and convert to lowercase and encode the string by
replacing each alphabet with the next alphabet in the alphabetical order.. If the alphabet
is z then replace it with the alphabet a. digits and special characters will remain the
same.
Example: If Input is Welcome 2019 Output: xfmdpnf 2019
17. Write a Program to input a string and convert to uppercase and check and display
whether the string is a UNIQUE String or not. The String is called Unique, when
characters present in the string are not repeated.
Example: Input: COMPUTER Output: It is an unique string.
18. Write a Program to input a sentence and display that are palindrome.
For Example: Input: Mom and Dad spoke in Malayalam.
Ouput: Mom Dad Malayalam
19. Write a Program to input a sentence and display the starting letter of each word in
uppercase. For Example: Input: Universal Serial Bus Output: USB
20. Write a Program to input a string and check whether it is a prime string or not. A string is
called prime string if the total number of characters in a string is a prime number.
Example: If Input is bluej Output: it is a prime string.
21. Write a program to input a number and check and display whether it is a Strontio number
or not. Strontio numbers are those 4-digit numbers when multiplied by 2 gives the same
digit in the hundreds and tens place. Example: 1386 is a Strontio number.
1386 x 2 = 2772 where the digit in the in the units and hundreds place is same.
22. Write a program to input a number and check whether it is a kaprekar number or not. A
number is described as follows:
Example 1:
9 is a kaprekar number.
The square of 9 is 81
Add the first two digits and last two digits 8 + 1 = 9 (equal to the input)
Example 2:
45 is a kaprekar number.
The square of 45 is 2025
Add the first two digits and last two digits 20 + 25 = 45 (equal to the input)
Example 3:
703 is a kaprekar number.
The square of 703 is 494209
Add the first two digits and last two digits 494 + 209 = 703 (equal to the input)
And so on…………………………
23. Write a program to input a number and find the sum of the squares of odd digits and sum
of the cubes of the even digits present in the number.
For Example: If input is 12345
Output: Sum of Squares of odd digits = 12+32+52= 1+9+25 = 35
Sum of Cubes of even digits= 23+43=8+64=72
24. Write a program to input a number and :-
(i) Count and display the number of Zero’s.
(ii) Find and display the smallest digit.
(iii) Find the sum of the first and the last digit.
25. Write a program to input a number and display the middle digit from the number only if
the digit count in the number is odd, otherwise display appropriate error message.
For Example: Input: 345 Output: Middle Digit is 4
26. Write a program to store 10 product names, their price quantity in 3 different arrays.
Calculate 10% discount on the total price (price*quantity) for each product and display
the output as
Product Name Price Quantity Total Price Amount after discount
----- ---- --------- -------- --------------
27. Write a program to input marks in a subject for 50 students and calculate:
(i) Subject Total by adding all the students’ marks in the subject.
(ii) Subject average [ SA= SubjectTotal/50]
28. Write a Program to input 10 integer elements in 2 different arrays. Output the elements
which are common in both the arrays at the corresponding index positions.
29. Write a program to input number of kgs of fruits used in 10 different places and the name
of the place in 2 different arrays and calculate
(i) Find the total Kgs of fruits and display.
(ii) Find and display the highest kg of fruits used and the place name.
(iii) Convert kgs to grams and display the result as
Place Kgs Grams
-- -- ---
30. Write a program to input 10 words in an array and
(i) Find and display the length of each word.
(ii) Find and display the word that has highest number of characters.
(iii) Convert and display the first letter of each word to uppercase.
(iv) count and display the no. of vowels in each word.
31. Write a Program to input 10 names and their corresponding course chosen in 2 different
arrays. Search for a name input by the user and display the corresponding course name
along with the student name, if found in the array. Display error message if he name is
not found using Linear Search Technique.
32. Write a Program to input 10 names in an array and search for a name input by the user
and display the index position if found in the array using Binary Search technique.
33. Write a Program to input 10 TV channels and their price in 2 different arrays. Search for
a TV channel name and display the corresponding price if found in the array using
Binary Search technique.
34. Write a Program to input 10 city names and arrange them in reverse alphabetical order
using bubble sort technique. Display the sorted array.
35. Write a Program to input weights of 10 different parcels in an array. Arrange the weights
in ascending order using selection sort technique. Display the sorted array.
36. Write a Program to input 10 state names and the language spoken in two different arrays.
Arrange the state names in ascending order along with the language spoken using
Bubble Sort technique. Display the result as
State Language
---- ------
37. Write a program to input 10 different characters in array and arrange them in descending
order using selection sort technique.