Class X Computer Applications Project
Class X Computer Applications Project
1. A Smith number is a composite number, whose sum of the digits is equal to the sum of
its prime factors.
For example:
4, 22, 27, 58, 85, 94, 121 ………. are Smith numbers.
Write a program in Java to enter a number and check whether it is a Smith number or not.
Sample Input: 666
Sum of the digits: 6 + 6 + 6 = 18
Prime factors are: 2, 3, 3, 37
Sum of the digits of the prime factors: 2 + 3 + 3 + (3 + 7) = 18
Thus, 666 is a Smith Number.
2. Write a program to input your 16 digit credit card number and find the sum of all
the digits present in it.
For e.g. Credit Card Number = 1234567890123456
Total = 66
3. Amicable numbers are two different numbers so related that the sum of the proper
divisors of each is equal to the other number.
For example, the smallest pair of amicable numbers is (220, 284); for the proper
divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the sum is 284; and
the proper divisors of 284 are 1, 2, 4, 71 and 142, of which the sum is 220.
A Happy number is defined by the following process: Starting with
any positive integer, replace the number by the sum of the squares of its digits, and
repeat the process until the number equals 1.
For example, 19 is happy, as the associated sequence is:
1 2 + 92 = 82
2 2
8 + 2 = 68
2 2
6 + 8 = 100
2 2 2
1 + 0 + 0 =1
Write a menu driven program using switch-case to send either character ‘A’ or ‘H’ as
parameter and input the numbers to check if it an Amicable Number or Happy
number or none of these.
4. Write a program to print the sum of the terms in the series mentioned below: -
s=x 2 +
Note: The value of n must be an even number. In case if it’s an odd number then print
the message – “Not possible”.
5. n is a perfect number if the sum of the factors of the number including 1 and excluding
itself is n.
For example,
6 =1+2+3 and
28=1+2+4+7+14
Define a class called numberProblems which has the following functions:
int nthPrime(int n) - method that returns the nth prime number give as
parameter.
void perfectNosBelow(int lim) - which first prints out the nth prime number given as
limit and then prints all perfect numbers less than lim.
Each perfect number should be printed on a separate
line along with its factors. For example, the output from
perfectNosBelow(500) will be:
500th prime number=3571
6 = (1,2,3)
28 = (1,2,4,7,14)
496 = ( (1, 2, 4, 8, 16, 31, 62, 124, 248)
6. Write a menu driven program using switch – case so that the computer prints either a
pattern or calculate the sum of the prime factors of a number input as parameter.
Choice 1 - Choice 2 -
1 To calculate the sum of the prime
13 factors of a number input as
135 parameter
1357 For e.g.
13579 Input: 30
(It’s a left aligned pattern) Output:
Sum of the prime factors = 2 + 3 + 5
= 10
sum =
(ii) void display (String word) with one String argument & print the following using
String function:
• Length of the word
• The last letter/character of the word
• New word leaving the starting alphabet
For e.g.
Input: Pray
Output:
Length of the word =4
The last letter of the word =y
New string leaving the starting alphabet = ray
[Note: In the second part, use appropriate String functions along with
System.out.println() statement to print the output]
9. Write a program to declare a single dimension array with 6 compartments and store 6
three-digit numbers only in it using scanner class.
Now, recreate the array in such a way that numbers present in the odd compartments are
sorted in descending order whereas numbers in the even compartments are formed by
adding the sum of the squares of the extreme digits with the cube of the middle digit.
For e.g. ,
Original array: -
847 739 848 492 975 348
Working:
82+43+72 973 82+43+82 942 92+73+52 843
Output:
177 973 192 942 449 843
10. Write a program to input 4 names of four characters length in a single dimension array
using scanner class. Add and print the ASCII value of each letter in individual names as
demonstrated in the example. Finally compare the values and print the name with highest
ASCII total. For e.g.
JACK = 74 + 65 + 67 + 75 = 281
SONY = 83 + 79 + 78 + 89 = 329 Winner is Sony with 329 points
JOHN = 74 + 79 + 72 + 78 = 303
TINA = 84 + 73 + 78 + 65 = 300
While doing the program care must be taken that: -
(i) The names should be of 4 letters only
(ii) Calculation should be done on the basis of all the Uppercase or Lowercase letters.
11. Write a program to enter a mixture of 10 positive even or odd numbers in a single
dimension array. Break the array into two different parts and print the numbers in
ascending order of even and odd numbers separately. For e.g.
Input:
77 89 63 258 452 10 846 159 2 74
Output:
Even Array:
2 10 74 258 452 846
Odd Array
63 77 89 159
12. Write a program to search a name in the array and print it along with the roll number.
For e.g.
Names in the array are Ashoke, Vijay, Raman, Karim, Aman
Roll numbers in the array are 5, 48, 40, 25, 2
Searched name: Raman
Roll Number 40
14. Write a program to print the sum of the terms in the series : -
Note:
For denominator operation, find the factorial of denominator first, and then its square
root.
15. A class numMagic contains two methods Niven() and Digit(), the description of which is
given below: -
boolean Niven(int n) - returns true if the number passed as parameter is a Niven number
or returns false if it is not. A Niven number is divisible by the sum
of its digits.
For e.g., if the number is 6804 then the method returns true since
6804 is divisible by 18, whereas if the number is 431 then the
method returns false.
int Digit(int num) - returns the sum of the number as shown below: -
For e.g. if the number is 563 then it returns,
=5+6+3
=11+3
=14
Write a program in Java to define the above two methods by creating the object of the class.
17. Write a program to determine the greatest two digit number that has maximum
factors. Print the number along with its factors.
18. Write a program to input nine numbers in a 3x3 matrix using scanner class and
then find out the transpose of the matrix. In a transposed matrix, the numbers in
the row are found in the column and vice – versa. For e.g.
25 3 19 25 36 91
36 27 70 3 27 58
91 58 47 19 70 47
19. 197 is a Keith Number because it follows a specific pattern demonstrated hereunder: -
197
Step 1
1+9+7
=17
Step 2
9+7+17
=33
Step 3
7+17+33
=57
Step 4
17+33+57
=107
Step 5
33+57+107
=197
Write a program to print all three digit Keith Numbers.
20. Write a program to calculate the amount collected by an Internet Cafe based on the
following conditions: -
Number of hours worked in the Internet Cafe should be input as a parameter. For example,
Input:
Number of hours worked = 12 hrs.
Output:
Total amount = Rs 135/-
st
1 hr. = Rs 20
nd th
2 to 4 hr. = Rs 15 x 3
= Rs 45
th th
5 to 10 hr. = Rs 10 x 6
= Rs 60
th th
11 to 12 hr. = Rs 5 x 2
= Rs 10
Total = Rs 20 + Rs 45 + Rs 60 + Rs 10
= Rs 135/-
---Best of Luck---