1. Program to check if the number is an Abundant Number or not.
A number is said to be an
abundant if the sum of the factors of the number excluding itself is greater than the number
itself.
Sample Input: 12
Factors of 12 are 1+2+3+4+6=16
Output: 12 is an Abundant Number
2. WAP to display the Prime factors of a number.
3. WAP to accept a word and display the piglatin form of the word.
Enter a word and shift all the letters which are available before the first vowel, towards the
end of the word and add AY at the end of the word.
Sample Input: TROUBLE
Sample output: OUBLETRAY
4. Define a class with the following specifications:
Class name: Cabservice
Instance variables: String taxino, String name, int d
Methods: Cabservice( ) a default constructor
Void input( ): to accept the input values for instance variables
Void calculate( ) : to calculate the bill as per the tariff given below:
Distance travelled Rate/km
0-5km 25
6-10km 35
>10km 45
Void display( ) : to display the details
Write a main ( ) to create an object and call all the methods.
5. WAP to accept a sentence and a word separately. Find and print the frequency of the given
word in the sentence.
Sample Input: the quick brown fox jumps over the lazy dog
word: the
Sample output: 2
6. WAP to store the names of all 20 students and their phone numbers correspondingly in a
two dimensional array. Enter a name separately and search it in the given list of names. If it
is present then display name with its phone number otherwise display a message “ name
not found”. Use Linear Search.
7. Design a class with the following specifications:
Class name: Railway
Instance variables: String name,coach ; int amt, total
Methods: void accept( ): to accept the name, coach and amt to store the basic amount of the
ticket
Void update( ): to update the total amount as per the coach selected
Type of Coach Amount
First AC 700
Second AC 500
Third AC 250
Sleeper none
Void display( ) : to display the details
Write a main ( ) to create an object and call all the methods.
8. WAP to accept a word and check if the word is a palindrome or not.
Sample Input: ARORA
Sample output: ARORA is a palindrome.
9. WAP to search for a number using Linear Search technique.
[Link] to search a number using Binary search technique.
[Link] to arrange the numbers using Selection sort technique.
[Link] to arrange the numbers using Bubble sort technique.
[Link] to accept 20 integers in SDA using menu driven approach display the following as
per the user’s choice:
a. All the perfect numbers stored in the array
b. All the buzz numbers stored in the array
A number whose sum of all factors (excluding 1 and the number itself) is same as the
number itself is a perfect number. A number that is divisible by 7 or has last digit as 7 is
a buzz umber.
[Link] to store the numbers in 3*4 matrix in DDA . Find the sum of all the elements and
display the sum.
[Link] to store the numbers in 2 DDA m[4][4] and n[4][4]. Find the sum of both the matrices
and store the result in p[4][4].
[Link] to accept 10 numbers and arrange the names using Bubble sort technique.
[Link] a class FoodWorld having the following description:
Instance Variables:
vegName : Name of the vegetable bought (String)
vegQty : Quantity of vegetable bought (int)
vegPrice : Price per unit of the vegetable (int)
bill : Total bill
Member Methods:
FoodWorld(name, qty, price) : To initialize the data members
void calcBill() : To calculate the total amount to be paid by the customer
void displayData() : To display the details in different lines as shown below
Name : Potatoes
Quantity : 2 Kg
Price : Rs 12
Bill : Rs 24
Write the main method to create the object of class FoodWorld and call the other methods to
display the output.
18. Define a class to search for a city input by the user from the list of country names and their
ISO code given below. If found display the country name along with its ISO code otherwise
display the message “Sorry! Country not found in the list”.
String cntr[]={“India”, ”China”, ”Japan”, “Australia”, “Ireland”};
String iso[]={“INR”, “CNY”, “JPY” , “AUD”, “EUR”};
[Link] a class to accept a number and check whether it is a Xylem or Phloem number. A
Number is said to be xylem number is the sum of extreme digits = sum of mean digits.
Otherwise it is a phloem number.
Eg: 12348 extreme digits 1,8, their sum 1+8=9, mean digits: 2,3,4, their sum 2+3+4=9
Sum of extreme digits = sum of mean digits Hence 12348 is a xylem number
76125 extreme digits 7+5=12, sum of mean digits 6+1+2=9,
Sum of extreme digits != sum of mean digits, hence it is a phloem number
Define a class to overload a function model() as follows
void model(String s1): Convert the string to uppercase and count and display the frequency of
each character of the string s1
void model(): Prints the below given pattern
Eg: String s=”SUPER”,
SUPER
* ***
SUP
* *
S
void model(char c1, char c2): to print the characters and their ASCII value between the range
c1 and c2 both inclusive in two different lines
Eg: c1=’A’, c2=’F’
A B C D E F
65 66 67 68 69 70
void model(double a, double b, double c): to print the value of k where k=r+
r= 𝑎 +𝑏+𝑐 and s=𝑎 +2𝑐
3 𝑏
Write a main method, create object, call the above functions