0% found this document useful (0 votes)
57 views60 pages

CA Programs 10 Final

Uploaded by

sujalmehra08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views60 pages

CA Programs 10 Final

Uploaded by

sujalmehra08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 60

LODHA WORLD SCHOOL,

PALAVA
Std X – Computer Applications Practical
File
Academic Year - 2022-2023

Submitted By-
Student’s Name
Unique Id -
LODHA WORLD SCHOOL, PALAVA

(PROJECT CERTIFICATE)

This is to certify that Master/Ms. _________________________


of Std. X bearing the unique ID ______________ has completed
the Computer Applications practical file with BLUEJ
programming.

Teacher’s Signature Date

External Examiner’s Signature

___________________

ACKNOWLEDGEMENT
I would like to express my special gratitude to my
Computer Applications Teacher Mrs. Sagoreeka
Pandey for helping me complete this project and as
well as our Principal madam Mrs. Aditi Banerji for
this project.

I would like to thank my parents who have been a


great support and also provided help.

Thanking You,
Sujal Mehra
----------------------------------------------------------------------
----------------------------------------------------------------------
----------------------------------------
Table of Contents
S.No. Program’s details Page No.
1. Write a program to display “Welcome to the world of Java”.

2. Write a program to perform mathematical operations (+,-,*, /) on 50


and 20
3. Write a program to display the area of a circle whose radius is 7.

4. Write a program to find the area and perimeter of a rectangle where


length = 6 and breadth =8.

5. Write a program to calculate perimeter and diagonal of a square. Take


side as an input.

6. Write a program to convert 3200 grams into Kg.


7. Write a program to find the simple interest and amount on Rs. 3000 at
5% for 2 years.

8. Write a program to convert Fahrenheit into Celsius. T(°C) = (T(°F) -


32) × 5/9
9. Write a program to convert number of 365 days into number of years,
number of months and number of days.
10. Write a program to input two unequal numbers. Display the numbers
after swapping their values in the variables without using a third
variable.
11. Write a program to print the marks in three subjects of a student. Print
the total and percentage marks. Display the grade on the basis of
following percentage.
Percentage Grade

Between 80 and 100 Grade A

Between 60 and 80 Grade B

Between 40 and 60 Grade C


Below 40 Grade D

12. Write a program to input a number and display the following ->
a) Logarithm of the entered number
b) Square root of the entered number
c) Cube root of the entered number
d) Round off the entered number
e) Absolute value of the given number
13. Write a program to input three angles of a triangle and check whether
a triangle is possible or not. If possible then check whether it is an
acute-angled triangle, right-angled or obtuse-angled triangle,
otherwise, display “Triangle is not possible”.
14. Write a program to input two unequal positive numbers and check
whether they are perfect square numbers or not. If the user enters a
negative number then the program displays the message “Square root
of a negative number can’t be determined.”
15. Write a program to accept a number and check whether the number is
divisible by 3 as well as 5. Otherwise, decide
a) If the number is divisible by 3 and not by 5.
b) If the number is divisible by 3 and not by 5.
c) If the number is neither divisible by 3 nor by 5.
16. A Pre-Paid taxi charges from the passenger as per the tariff given
below:
Distance Rate

Up to 5 km ₹ 100

For the next 10 km ₹ 10/km

For the next 10 km ₹ 8/km

More than 25 km ₹ 5/km


Write a program to input the distance covered and calculate the
amount paid by the passenger. The program displays the printed bill
with the details given below:
Taxi No. :
Distance covered :
Amount :
17. Mr. Kumar is an LIC agent. He offers discount to his policy holders
on the annual premium. However, he also gets commission on the
sum assured as per the given tariff.
Sum Assured Discount Commission

Up to ₹ 1,00,000 5% 2%

₹ 1,00,001 and up to ₹ 2,00,000 8% 3%

₹ 2,00,001 and up to ₹ 5,00,000 10% 5%

More than ₹ 5,00,000 15% 7.5%

Write a program to input name of the policy holder, the sum assured
and first annual premium. Calculate the discount of the policy holder
and the commission of the agent. The program displays all the details
as:
Name of the policy holder :
Sum assured :
Premium :
Discount on the first premium :
Commission of the agent :
18. The equivalent resistance of series and parallel connections of two
resistances are given by the formula:
(a) R1 = r1 + r2 (Series)
(b) R2 = (r1 * r2) / (r1 + r2) (Parallel)
Using a switch case statement, write a program to enter the value of
r1 and r2. Calculate and display the equivalent resistances
accordingly.
19. Write a program to print the multiplication table of 12.
20. Write a program to input a number and count the number of digits.
The program further check whether it contains odd number of digit or
even.
21. Write a program to input cost price and selling price of an article. If
the selling price is more than selling price than calculate the profit or
profit percentage otherwise calculate loss and loss percentage.
22. Write a menu driven program to accept a number from the user
whether it is a palindrome number or a perfect number.
23. Write a program in java to find the sum of the given series:
a) S = a2 + a2/2 + a2/3 + a2/4 + a2/5
b) 0+ 7 + 26 + 63
c) S = 1+1/2! + 1/3! + ¼! + 1/5!

24. Using Switch statement, write a menu driven program for the
following:
i. To find and display the sum of the series given below:
S= x1 – x2 + x3 - x4 + x5 -x6 + …….. -x20
ii. To display the following series:
1, 11, 111, 1111, 11111,..
25. Write a program to input a number and check whether it is a ‘Spy
number’ or not
26. Write a program in BLUEJ to find the factorial of a number.
27. Write a program to find the sum of the following
S = 1! + 2! + 3! + 4!

28. Write a program in BLUEJ to display the following Fibonacci series:


1, 1, 2,3,5,8, 13, 21, 34
29. Write a program to generate the following patterns using iteration
loops.
a) b)
1
#####
#### 12
### 123
## 1234
# 12345
30. Write a program to print the following patterns.
a. b.
* 54321
** 4321
*** 321
**** 2 1
***** 1
c. d.
55555 2
4444 24
3 33 246
2 2 24 68
1 2 4 6 8 10
31. Write a program in BLUEJ to check whether the entered number is an
“Automorphic number” or not.
For Example: 25 is an Automorphic number as is square is 625 and
25 is present as the last two digits.
32. Write a program in BLUEJ to input a number and display the new
number after reversing the digits of the original number. The program
also displays the absolute difference between the original number and
the reverse number.
For Example:
Original number: 123
Reverse number : 321
Absolute difference = -198
33. Write a program in BLUEJ to input a number and display the smallest
digit and largest digit of the entered number.
34. Write a program in BLUEJ to input a number and display the sum of
the digits of the entered number.
35. Write a program in BLUEJ to input a number and display the product
of the digits of the entered number.
36. Write a program to input a number and check whether it is a ‘Duck
number’ or not.
37. Write a program to input a number and check whether it is a ‘Niven
number’ or not.
38. Define a class 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 vehicle number and hours
void calculate() - To compute the parking charge at the rate of Rs.3 for
the first hour or part thereof, and Rs.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.
39. Define a class taximeter having the following descriptions:
Data member/instance variables:
int taxi_no To store taxi number
String name To store passenger’s name
int Km To store number of kilometers travelled
Member functions:
void input() Takes the input to store taxi number,
passenger’s name and number of kilometers
travelled
void calculate() To calculate the bill for a customer according to
given conditions.

Kilometers travelled Rate/Km


<= 2 kms Rs. 25
Between 2 Kms and Rs. 10
10 Kms
Between 10 Km and Rs 15
20 Kms
Above 20Kms Rs 20

void display() To display the taxi number, passenger’s name,


number of kilometers travelled and Bill
amount.
public static
Create an object in the main method to call all the
void main()
above functions.
40. Define a class ‘Employee’ having the following description:
Data Members
int pan To store personal account number
String name To store name
double taxincome To store annual taxable income
double tax To store tax that is calculated
Member Methods
void input() Stores the pan number, name and taxable
income
void cal() Calculate tax on taxable income
void display() To display the details of an employee

Calculate the tax based on the given conditions and display the output
as per the given format.

Total Annual Taxable Income Tax Rate


Upto ₹ 2,50,000 No tax
From ₹ 2,50,001 to ₹ 5,00,000 10% of the income exceeding ₹
2,50,000
From ₹ 5,00,001 to ₹ 10,00,000 ₹ 30,000 + 20% of the income
exceeding ₹ 5,00,000
Above ₹ 10,00,000 ₹ 30,000 + 20% of the income
exceeding ₹ 10,00,000
41. Define a class ‘Mobike’ having the following description:
Data Members
int bno To store the bike number
int phno To store the phone number
String name To store the name of the customer
int days To store the number of the days the bike is
taken on rent
int charge To calculate and store the rental charges

Member Methods
void input() To input and store the details of customer
void compute() To compute the rental charge
void display() To display the details of customer
Calculate the rent based on the given conditions:
No.of days Rent charges
For first 5 days ₹ 500 per day
For next 4 days ₹ 400 per day
Rest of the days ₹ 200 per day
42. Define a class to overload a function polygon() as follows:
a) 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.
b) void polygon(int x, int y) – with two integer arguments that
draws a filled rectangle of length x and breadth y, using the
symbol ‘@’.
43. Write a class with the name Perimeter using function overloading that
computes the perimeter of a square, rectangle and a circle.
44. Write a program in Java to find the number of vowels in a string.
For example: Input is “COMPUTER APPLICATIONS”
Output is :- Number of vowels in the given string is 8.
45. Write a program to accept a non-palindrome word and display the
new word after making it a palindrome.
For Example: Input : ICSE
Output : ICSEESCI
46. Write a program to find the frequency of each vowel in a string.
For example: Input “COMPUTER APPLICATIONS”
Output :- Frequency of vowel ‘A’ is 2.
Frequency of vowel ‘E’ is 1.
Frequency of vowel ‘I’ is 2.
Frequency of vowel ‘O’ is 2.
Frequency of vowel ‘U’ is 1.

47. Write a program to accept a string and display the new string after
removing all the vowels present in it.
For example : Input “COMPUTER APPLICATIONS”
Output : CMPTER PPLCTNS
48. Write a program in Java to accept two characters and display the sum
and difference of their ASCII value.
49. Write a program to accept an alphabet character and display the next
alphabet accordingly.
For example: Input –‘a’ Output – ‘b’.

*************

Java (Blue J) Programs ⇒


1) class p1
{
public static void main()
{
System.out.println("Welcome to the world of Java");
}
}

Variable Type Description

– – -

2) class p2
{
public static void main()
{
int a=50,b=20;
int Sum= a+b;
int Sub= a-b;
double Multi= a*b;
double Divide= a/b;
System.out.println(Sum);
System.out.println(Sub);
System.out.println(Multi);
System.out.println(Divide);
}
}
Variable Type Description

a Integer To store the value 50

b Integer To store the value 20

Sum Integer Addition of a and b

Sub Integer Subtraction of a and b

Multi Double Multiplication of a and b

Divide Double Division of a and b

3) public class p3
{
public static void main(String args[])
{
int r=7;
double Area= 3.14*r*r;
System.out.println("Area="+Area);
}
}

Variable Type Description

r Integer Radius of the Circle

Area Double Area of Circle

4) public class p4
{
public static void main()
{
int length=6;
int breadth=8;
double area=(length*breadth);
double perimeter=2*(length+breadth);
System.out.println("Area = "+area);
System.out.println("Perimeter = "+perimeter);
}
}

Variable Type Description

length Integer Length of Rectangle

breadth Integer Breadth of Rectangle

area Double Area of Rectangle

perimeter Double Perimeter of Rectangle

5) import java.util.Scanner;
public class p5
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the side of the square");
double side =sc.nextDouble();
double perimeter =4*side;
double diagonal =side*Math.sqrt(2);
System.out.println("Perimeter of the square : "+perimeter);
System.out.println("Length of the diagonal : "+diagonal);
}
}

Variable Type Description

side Double Side of Square

perimeter Double Perimeter of Square

diagonal Double Diagonal of Square


6) public class p6
{
public static void main()
{
double g = 3200;
double kg =g/1000;
System.out.println("Value of g in kg = "+kg);
}
}

Variable Type Description

g Double To store 3200 in grams

kg Double To store the value 3200 in


kilograms

7) public class p7
{
public static void main()
{
double P=3000;
double R=5;
double T=2;
double SI=(P*R*T)/100;
double A=P+SI;
System.out.println("Simple Interest = "+SI);
System.out.println("Amount = "+A);
}
}

Variable Type Description

P Double Principal

R Double Rate of Interest

T Double Time Period

SI Double Simple Interest


A Double Amount

8) public class p8
{
public static void main(double F)
{
double TC =(F-32)*5/9;
System.out.println("Value of Fahrenheit in Celsius = "+TC);
}
}

Variable Type Description

F Double Fahrenheit

TC Double Celsius

9) class p9
{
static void find()
{
int ndays=365;
int year, week, days;
int dweek = 7;
year = ndays / 365;
week = (ndays/dweek);
days = ndays/1;
System.out.println("years = " + year);
System.out.println("weeks = " + week);
System.out.println("days = " + days);
}
}

Variable Type Description

ndays Integer No. of days

year, week, days Integer To store the value in year, week,


days

dweek Integer Days in week

10) import java.util.Scanner;


public class p10
{
public static void main()
{
Scanner in = new Scanner(System.in);
System.out.println("Enter two unequal numbers");
System.out.print("Enter the first number: ");
int a = in.nextInt();
System.out.print("Enter the second number: ");
int b = in.nextInt();
a = a + b;
b = a - b;
a = a - b;
System.out.println("a = " + a + " b = " + b);
}
}

Variable Type Description

a Integer The First Number

b Integer The Second Number

11) import java.util.Scanner;


public class p11
{
public static void main(String args [])
{
Scanner sc = new Scanner(System.in);
char ch=' ';
System.out.println("Enter the marks in a,b and c subjects");
double a=sc.nextDouble();
double b=sc.nextDouble();
double c=sc.nextDouble();
double Total=a+b+c;
System.out.println("total marks obtained = "+ Total);
double percentage =(Total/300)*100;
if(percentage>=80&&percentage<=100)
ch='A';
if(percentage>=60&&percentage<80)
ch='B';
if(percentage>=40&&percentage<60)
ch='C';
if(percentage<40)
ch='D';
System.out.println("percentage = "+percentage);
System.out.println("Grade = "+ch);
}
}

Variable Type Description

ch Char To store char type of data/ Grade


Obtained

a, b, c Double To enter marks in a,b,c subjects

Total Double Total Marks Obtained

percentage Double Percentage Obtained

12) import java.util.Scanner;


public class p12
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
double n=sc.nextDouble();
System.out.println("Logarithm of the entered number = "+Math.log(n));
System.out.println("Square root of the entered number = "+Math.sqrt(n));
System.out.println("Cube root of the entered number = "+ Math.cbrt(n));
System.out.println("Round off the entered number = "+Math.round(n));
System.out.println("Absolute value of the given number = "+Math.abs(n));
}
}

Variable Type Description

n Double The Number Entered

13) import java.util.Scanner;


public class p13
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the first Angle: ");
int A1 = in.nextInt();
System.out.print("Enter the second Angle: ");
int A2 = in.nextInt();
System.out.print("Enter the third Angle: ");
int A3 = in.nextInt();
int AngleSum = A1 + A2 + A3;
if (AngleSum == 180 && A1 > 0 && A2 > 0 && A3 > 0)
{
if (A1 < 90 && A2 < 90 && A3 < 90)
{
System.out.println("Acute-Angled TriAngle");
}
else if (A1 == 90 || A2 == 90 || A3 == 90)
{
System.out.println("Right-Angled TriAngle");
}
else {
System.out.println("Obtuse-Angled TriAngle");
}
}
else
{
System.out.println("TriAngle is not possible");
}
}
}

Variable Type Description

A1, A2, A3 Integer First , Second and Third Angle

AngleSum Integer Sum of the Angles of a Triangle

14) import java.util.Scanner;


public class p14
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the first number: ");
int a = in.nextInt();
System.out.print("Enter the second number: ");
int b = in.nextInt();
if (a < 0 || b < 0)
{
System.out.println("Square root of a negative number can't be determined");
}
else
{
double sqrtA = Math.sqrt(a);
double sqrtB = Math.sqrt(b);
double PsqA = sqrtA - Math.floor(sqrtA);
double Psqb = sqrtB - Math.floor(sqrtB);
if (PsqA == 0 && Psqb == 0)
{
System.out.println("They are perfect square numbers.");
}
else if (PsqA == 0)
{
System.out.println(a + " is a perfect square number.");
System.out.println(b + " is not a perfect square number.");
}
else if (Psqb == 0)
{
System.out.println(a + " is not a perfect square number.");
System.out.println(b + " is a perfect square number.");
}
else
{
System.out.println("Both are not perfect square numbers.");
}
}
}
}

Variable Type Description

a, b Integer First and Second Number

sqrtA, sqrtB Double Square Root of a and b

PsqA, PsqB Double Perfect Square Number

15) import java.util.Scanner;


public class p15
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = in.nextInt();
if (num % 3 == 0 && num % 5 == 0)
System.out.println("Divisible by 3 and 5");
else if (num % 3 == 0)
System.out.println("Divisible by 3 but not by 5");
else if (num % 5 == 0)
System.out.println("Divisible by 5 but not by 3");
else
System.out.println("Neither divisible by 3 nor by 5");
}
}

Variable Type Description

num Integer The Number Entered

16) import java.util.Scanner;


public class p16
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Taxi Number: ");
String taxiNo = in.nextLine();
System.out.print("Enter distance travelled: ");
int dis = in.nextInt();
int fare = 0;
if (dis <= 5)
fare = 100;
else if (dis <= 15)
fare = 100 + (dis - 5) * 10;
else if (dis <= 25)
fare = 100 + 100 + (dis - 15) * 8;
else
fare = 100 + 100 + 80 + (dis - 25) * 5;
System.out.println("Taxi No: " + taxiNo);
System.out.println("Distance covered: " + dis);
System.out.println("Amount: " + fare);
}
}
Variable Type Description

taxiNo String Taxi Number

dis Integer Distance Travelled

fare Integer Total Amount

17) import java.util.Scanner;


public class p17
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Name: ");
String name = in.nextLine();
System.out.print("Enter Sum Assured: ");
double sum = in.nextDouble();
System.out.print("Enter First Premium: ");
double prem = in.nextDouble();
double dis = 0.0, comm = 0.0;
if(sum <= 100000){
dis = prem * 5.0 / 100.0;
comm = sum * 2.0 / 100.0;
}
else if(sum <= 200000){
dis = prem * 8.0 / 100.0;
comm = sum * 3.0 / 100.0;
}
else if(sum <= 500000){
dis = prem * 10.0 / 100.0;
comm = sum * 5.0 / 100.0;
}
else{
dis = prem * 15.0 / 100.0;
comm = sum * 7.5 / 100.0;
}
System.out.println("Name of the policy holder: " + name);
System.out.println("Sum assured: " + sum);
System.out.println("Premium: " + prem);
System.out.println("Discount on the first premium: " + dis);
System.out.println("Commission of the agent: " + comm);
}
}

Variable Type Description

name String Name of the policy holder

sum Double Sum assured

prem Double Premium

dis Double Discount on the first premium

comm Double Commission of the agent

18) import java.util.Scanner;


public class p18
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("1. Series");
System.out.println("2. Parallel");
System.out.print("Enter your choice: ");
int choice = in.nextInt();
boolean isChoiceValid = true;
System.out.print("Enter r1: ");
double r1 = in.nextDouble();
System.out.print("Enter r2: ");
double r2 = in.nextDouble();
double eqr = 0.0;
switch (choice) {
case 1:
eqr = r1 + r2;
break;
case 2:
eqr = (r1 * r2) / (r1 + r2);
break;
default:
isChoiceValid = false;
System.out.println("Incorrect choice");
break;
}
if (isChoiceValid)
System.out.println("Equivalent resistance = " + eqr);
}
}

Variable Type Description

choice Integer The choice of the user

isChoiceValid Boolean To check if condition is True or


False

r1, r2 Double To input Resistance 1 and


Resistance 2

eqr Double Equivalent resistance

19) public class p19


{
public static void main(String[] args)
{
int num = 12;
for(int i = 1; i <= 10; ++i)
{
System.out.println(num+" * "+i+" = "+num*i);
}
}
}

Variable Type Description

num Integer To store the the number 12

i Integer Counter Variable

20) import java.util.Scanner;


public class p20
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter number: ");
int num = sc.nextInt();
int ds = 0;
while (num != 0)
{
ds++;
num/= 10;
}

System.out.println("Number of digits = " + ds);


if (ds % 2 == 0)
System.out.println("Even number of digits");
else
System.out.println("Odd number of digits");
}
}

Variable Type Description

num Integer The Number Entered

ds Integer Number of digits

21) import java.util.Scanner;


public class p21
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter selling price: ");
double sp = sc.nextDouble();
System.out.print("Enter cost price: ");
double cp = sc.nextDouble();
double p = sp - cp;
double percent = Math.abs(p) / cp * 100;
if (p > 0)
{
System.out.println("Profit = " + p);
System.out.println("Profit % = " + percent);
}
else if (p < 0)
{
System.out.println("Loss = " + Math.abs(p));
System.out.println("Loss % = " + percent);
}
else
{
System.out.println("Neither profit nor loss");
}
}
}

Variable Type Description

sp Double Selling Price

cp Double Cost Price

p Double Profit

percent Double Percentage

22) import java.util.Scanner;


public class p22
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter your number: ");
int num = sc.nextInt();
System.out.println("Enter 1 for Palindrome number");
System.out.println("Enter 2 for Perfect number");
System.out.print("Enter your choice: ");
int ch = sc.nextInt();
switch (ch)
{
case 1:
int p = num;
int r = 0;
do
{
int d = num % 10;
r = r * 10 + d;
num = num / 10;
}
while(num!=0);
if (r == p)
System.out.println("Number is palindrome");
else
System.out.println("Number is not palindrome");
break;
case 2:
int sum = 0;
for (int i = 1; i <= num / 2; i++)
{
if (num % i == 0)
{
sum += i;
}
}
if (num == sum)
System.out.println(num + " is a perfect number");
else
System.out.println(num + " is not a perfect number");
break;
default:
System.out.println("Incorrect Choice");
break;
}
}
}

Variable Type Description

num Integer The Number Entered

ch Integer Choice of the User

p, r, d Integer To store integer type of data

i Integer Counter Variable

sum Integer To store the sum

23)a) import java.util.Scanner;


public class p23a
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int a = sc.nextInt();
int sum = 0;
for (int i = 1; i <= 5; i++)
{
sum += (Math.pow(a,2)/i);
}
System.out.println("Sum:" +sum);
}
}

Variable Type Description

a Integer The Number Entered

i Integer Counter Variable

sum Integer The Sum of the Series

b) public class p23b


{
public static void main(String args[])
{
System.out.println("The sum of the series");
System.out.println("S = 0 + 7 + 26 + 63 is");
int sum = 0;
sum = 0+7+26+63;
System.out.println(""+sum);
}
}

Variable Type Description

sum Integer The Sum of the Series


c) public class p23c
{
public static void main(String args[])
{
double sum = 0.0;
for (int i = 1; i <= 5; i++)
{
long fact = 1;
for (int j = 1; j <= i; j++)
{
fact *= j;
}
sum += (1.0 / fact);
}
System.out.println("Sum=" + sum);
}
}

Variable Type Description

sum Double The Sum of the Series

i, j Integer Counter Variables

fact Long Factorial of the Number

24) import java.util.Scanner;


public class p24
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter 1 for Sum of the series");
System.out.println("Enter 2 for Display series");
System.out.print("Enter your choice: ");
int ch = sc.nextInt();
switch (ch)
{
case 1:
System.out.print("Enter the value of x: ");
int x = sc.nextInt();
int sum = 0;
for (int i = 1; i <= 20; i++)
{
int term = (int)Math.pow(x, i);
if (i % 2 == 0)
sum -= term;
else
sum += term;
}
System.out.println("Sum=" + sum);
break;
case 2:
int term = 1;
for (int i = 1; i <= 5; i++)
{
System.out.print(term + " ");
term = term * 10 + 1;
}
break;
default:
System.out.println("Incorrect Choice");
break;
}
}
}

Variable Type Description

ch Integer To Enter the User’s Choice

x Integer To store the value entered by the


User

sum Integer To store the sum


i Integer Counter Variable

term Integer To store the integer type of data


in the variable term

25) import java.util.Scanner;


public class p25
{
public static void main(String args[])
{
int n,product=1,sum=0;
int a;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the Number:");
n = sc.nextInt();
while (n > 0)
{
a = n % 10;
sum = sum + a;
product = product * a;
n = n / 10;
}

if (sum == product)
System.out.println("It is Spy Number");
else
System.out.println("It is not Spy Number");

}
}

Variable Type Description

n Integer The Number Entered

a Integer To store integer type of data

product Integer To store the product of the


number

sum Integer To store the sum of the number


26) import java.util.Scanner;
public class p26
{
public static void main(String args[])
{
int i,n,fac=1;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
n = sc.nextInt();
for( i = 1; i <= n; i++)
{
fac *= i;
}
System.out.print("The factorial of the number is "+fac);
}
}

Variable Type Description

i Integer Counter Variable

n Integer The Number Entered

fac Integer The Factorial of the Number

27) public class p27


{
public static void main(String args[])
{
int i,n=4,fac=1,sum=0;
for( i = 1; i <= n; i++)
{
fac *= i;
sum += fac;
}
System.out.print("The sum of the following is "+sum);
}
}
Variable Type Description

i Integer Counter Variable

n Integer To store the value 4 in the


variable n

fac Integer Factorial of the Number

sum Integer The Sum of the following Series

28) public class p28


{
public static void main()
{
int a = 0;
int b = 0;
int c = 1;
for(int i=1;i<=10;i++)
{
a=b;
b=c;
c=a+b;
System.out.print(a+" ");
}
}
}

Variable Type Description

a, b, c Integer To store integer type of data

i Integer Counter Variable

29)a) public class p29a


{
public static void main(String args[])
{
for (int i = 1; i <=5; i++)
{
for (int j = 5; j >= i; j--)
{
System.out.print("#");
}
System.out.println();
}
}
}

Variable Type Description

i, j Integer Counter Variables

b) public class p29b


{
public static void main(String args[])
{
for (int i = 1; i <=5; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+"");
}
System.out.println();
}
}
}

Variable Type Description

i, j Integer Counter Variables

30)a) public class p30a


{
public static void main(String args[])
{
for (int i = 1; i <=5; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print("*"+" ");
}
System.out.println();
}
}
}

Variable Type Description

i, j Integer Counter Variables

b) public class p30b


{
public static void main(String args[])
{
for (int i = 1; i <=5; i++)
{
for (int j = i; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Variable Type Description

i, j Integer Counter Variables

c) public class p30c


{
public static void main(String args[])
{
for (int i = 5; i >=1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(i+" ");
}
System.out.println();
}
}
}

Variable Type Description

i, j Integer Counter Variables

d) public class p30d


{
public static void main(String args[])
{
for (int i = 2; i <=10; i=i+2)
{
for (int j = 2; j <= i; j=j+2)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Variable Type Description

i, j Integer Counter Variables

Q31) //Program to find Automorphic number of two digit numbers only


import java.util.*;
class p31
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
int sq = n * n;
int r = sq % 100;
if (r==n)
System.out.println("It is an Automorphic Number");
else
System.out.println("It is not an Automorphic Number");
}
}

Variable Type Description

n Integer The Number Entered

sq Integer Square Root

r Integer To store integer type of value

Q32) import java.util.*;


class p32
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
int a=n,r=0,rem,ab;
while(n!=0)
{
rem = n % 10;
r = r * 10 + rem;
n /= 10;
}
ab = r - a;
System.out.println("Reverse Number:"+r);
System.out.println("Absolute Difference:"+ Math.abs(ab));
}
}

Variable Type Description

n Integer The Number Entered

a Integer To store integer type of value

r Integer Reverse Number

rem Integer Remainder

ab Integer Absolute Difference

Q33) import java.util.*;


class p33
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
int max=0,min=9;
while(n>0)
{
int r = n % 10;
max = Math.max(max,r);
min = Math.min(min,r);
n /= 10;
}
System.out.println("Largest Digit:"+max);
System.out.println("Smallest Digit:"+min);
}
}

Variable Type Description

n Integer The Number Entered

max Integer Largest Digit

min Integer Smallest Digit

r Integer To store integer type of value

Q34) import java.util.*;


class p34
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
int s=0;
while(n>0)
{
s = s + (n % 10);
n /= 10;
}
System.out.println("Sum of the digits:"+s);
}
}
Variable Type Description

n Integer The Number Entered

s Integer Sum of the digits

Q35) import java.util.*;


class p35
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
int p=1;
while(n>0)
{
p = p * (n % 10);
n /= 10;
}
System.out.println("Product of the digits:"+p);
}
}

Variable Type Description

n Integer The Number Entered

p Integer Product of the digits

Q36) import java.util.*;


class p36
{
public static void main()
{
Scanner sc = new Scanner(System.in);
int n,a,b,c=0;
System.out.println("Enter the number");
n=sc.nextInt();
while(n>0)
{
a = n % 10;
if(a==0)
c++;
else
b=a;
n = n / 10;
}
if(c>0)
System.out.println("It is a duck number");
else
System.out.println("It is not a duck number");
}
}

Variable Type Description

n Integer The Number Entered

a Integer To store integer type of value

b Integer To store integer type of value

c Integer To store integer type of value

Q37) import java.util.*;


class p37
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n = sc.nextInt();
int a=n,s=0,d;
while(n!=0)
{
d = n % 10;
n /= 10;
s += d;
}
if(s!=0 && a%s==0)
System.out.println("It is a niven number");
else
System.out.println("It is not a niven number");
}
}

Variable Type Description

n Integer The Number Entered

a Integer To store integer type of value

s Integer To store integer type of value

d Integer To store integer type of value

Q38) import java.util.*;


class ParkingLot
{
int vno,hours;
double bill;
void input()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Vehicle No");
vno = sc.nextInt();
System.out.println("Enter the hours");
hours = sc.nextInt();
}
void calculate()
{
if(hours<=1)
{
bill = 3.0;
}
else
{
bill = 3.0 + (hours - 1) * 1.5;
}
}
void display()
{
System.out.println("Vehicle No:"+vno);
System.out.println("Hours:"+hours);
System.out.println("Total Amount:"+bill);
}
public static void main()
{
ParkingLot ob = new ParkingLot();
ob.input();
ob.calculate();
ob.display();
}
}

Variable Type Description

vno Integer Vehicle No

hours Integer No of Hours

bill Double Total Amount

Q39) import java.util.*;


class taximeter
{
int taxi_no,Km,bill;
String name;
void input()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter Name");
name = sc.nextLine();
System.out.println("Enter Taxi Number");
taxi_no = sc.nextInt();
System.out.println("Enter Km");
Km = sc.nextInt();
}
void calculate()
{
if(Km<=2)
{
bill = 25 * Km;
}
else if(Km>2 && Km<=10)
{
bill = 10 * Km;
}
else if(Km>10 && Km<=20)
{
bill = 15 * Km;
}
else
{
bill = 20 * Km;
}
}
void display()
{
System.out.println("Name:"+name);
System.out.println("Taxi No:"+taxi_no);
System.out.println("Km:"+Km);
System.out.println("Total Amount:"+bill);
}
public static void main()
{
taximeter ob = new taximeter();
ob.input();
ob.calculate();
ob.display();
}
}
Variable Type Description

taxi_no Integer Taxi No

Km Integer No of Km

bill Integer Total Amount

name String Name entered by User

Q40) import java.util.*;


class Employee
{
int pan;
String name;
double taxincome,tax;
void input()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter Name");
name = sc.nextLine();
System.out.println("Enter Pan Number");
pan = sc.nextInt();
System.out.println("Enter Taxable Income");
taxincome = sc.nextDouble();
}
void cal()
{
if(taxincome<=250000)
{
tax = 0;
}
else if(taxincome>=250001 && taxincome<=500000)
{
tax = 0.1 * (taxincome - 250000);
}
else if(taxincome>=500001 && taxincome<=1000000)
{
tax = 30000 + (0.2 * (taxincome - 500000));
}
else
{
tax = 30000 + (0.2 * (taxincome - 1000000));
}
}
void display()
{
System.out.println("Name:"+name);
System.out.println("Pan No:"+pan);
System.out.println("Tax Income:"+taxincome);
System.out.println("Tax:"+tax);
}
public static void main()
{
Employee ob = new Employee();
ob.input();
ob.cal();
ob.display();
}
}

Variable Type Description


pan Integer Pan No

name String Name entered by User

taxincome Double Taxable Income

tax Double Tax

Q41) import java.util.*;


class Mobike
{
int bno,phno,days,charge;
String name;
void input()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter Name");
name = sc.nextLine();
System.out.println("Enter Bike Number");
bno = sc.nextInt();
System.out.println("Enter Phone Number");
phno = sc.nextInt();
System.out.println("Enter No of Days");
days = sc.nextInt();
}
void compute()
{
if(days<=5)
{
charge = days * 500;
}
else if(days<=9)
{
charge = 2500 + ((days - 5) * 400);
}
else
{
charge = 2500 + 1600 + ((days - 9) * 200);
}
}
void display()
{
System.out.println("Name:"+name);
System.out.println("Bike Number:"+bno);
System.out.println("Phone Number:"+phno);
System.out.println("No of Days:"+days);
System.out.println("Charge:"+charge);
}
public static void main()
{
Mobike ob = new Mobike();
ob.input();
ob.compute();
ob.display();
}
}

Variable Type Description

bno Integer Bike No

phno Integer Phone No

days Integer No of Days

charge Integer Total Amount

name String Name entered by User

Q42) import java.util.*;


class p42
{
void polygon(int n,char ch)
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
System.out.print(ch);
}
System.out.println();
}
}
void polygon(int x,int y)
{
for (int i = 1; i <= y; i++)
{
for (int j = 1; j <= x; j++)
{
System.out.print('@');
}
System.out.println();
}
}
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number and a character:");
int a = sc.nextInt();
char ch1 = sc.next().charAt(0);
System.out.println("Enter two numbers:");
int b = sc.nextInt();
int c = sc.nextInt();
p42 ob = new p42();
ob.polygon(a,ch1);
ob.polygon(b,c);
}
}
Variable Type Description

n Integer Side of the square

ch Character Square filled with a character

i Integer Counter variable

j Integer Counter variable

x Integer Length of the rectangle

y Integer Breadth of the rectangle

a Integer To store the value of n(side of


square)

ch1 Character To store the value of ch

b Integer To store the length

c Integer To store the breadth

Q43) import java.util.*;


class Perimeter
{
void perimeter(int s)
{
int ps = 4 * s;
System.out.println("Perimeter of square:"+ps);
}
void perimeter(int l,int b)
{
int pr = 2 * (l + b);
System.out.println("Perimeter of rectangle:"+pr);
}
void perimeter(float r)
{
double pc = Math.round(6.28 * r);
System.out.println("Perimeter of circle:"+pc);
}
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter side:");
int a = sc.nextInt();
System.out.println("Enter length and breadth:");
int b = sc.nextInt();
int c = sc.nextInt();
System.out.println("Enter radius:");
float r = sc.nextFloat();
Perimeter ob = new Perimeter();
ob.perimeter(a);
ob.perimeter(b,c);
ob.perimeter(r);
}
}

Variable Type Description


s Integer Side of the square

ps Integer Perimeter of square

l Integer Length of the rectangle

b Integer Breadth of the rectangle

pr Integer Perimeter of rectangle

r Float Radius of circle

pc Double Perimeter of circle

a Integer To store the side

b Integer To store the length

c Integer To store the breadth

r Float To store the radius

Q44) import java.util.*;


class p44
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string");
String st = sc.nextLine();
int k,i,count=0;
char ch;
k = st.length();
String st1 = st.toUpperCase();
for(i = 0 ; i < k; i++)
{
ch = st1.charAt(i);
if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
count++;
}
System.out.println("Number of vowels in the given string is:"+count);
}
}
Variable Type Description

st String The string entered

k Integer The length of the string

i Integer Counter variable

count Integer No. of vowels in the string

ch Character To extract the characters of the


string

Q45) import java.util.*;


class p45
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a word:");
String st = sc.next().toUpperCase();
String reverse ="";
for(int i = st.length()-1 ; i >= 0 ; i--)
{
reverse+=st.charAt(i);
}
if(st.equals(reverse))
{
System.out.println("It is a Palindrome String");
}
else
{
System.out.println("It is not a Palindrome String");
System.out.println("Palindrome String :"+(st+reverse));
}
}
}
Variable Type Description

st String The string entered(and in


uppercase)

reverse String The reverse of the string

i Integer Counter variable

Q46) import java.util.*;


class p46
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string");
String st = sc.nextLine();
int k,i,ac=0,ec=0,ic=0,oc=0,uc=0;
char ch;
k = st.length();
String st1 = st.toUpperCase();
for(i = 0 ; i < k ; i++)
{
ch = st1.charAt(i);
if(ch=='A')
ac++;
if(ch=='E')
ec++;
if(ch=='I')
ic++;
if(ch=='O')
oc++;
if(ch=='U')
uc++;
}
System.out.println("Frequency of vowel ‘A’:"+ac);
System.out.println("Frequency of vowel ‘E’:"+ec);
System.out.println("Frequency of vowel ‘I’:"+ic);
System.out.println("Frequency of vowel ‘O’:"+oc);
System.out.println("Frequency of vowel ‘U’:"+uc);
}
}

Variable Type Description

st String The string entered

k Integer The length of the string

i Integer Counter variable

ac Integer Frequency of vowel ‘A’

ec Integer Frequency of vowel ‘E’

ic Integer Frequency of vowel ‘I’

oc Integer Frequency of vowel ‘O’

uc Integer Frequency of vowel ‘U’

ch Character To extract the characters of the


string

st1 String The string entered in uppercase

Q47) import java.util.*;


class p47
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string");
String st = sc.nextLine().toUpperCase();
int k = st.length();
String st1 = "";
for (int i = 0; i < k; i++)
{
char ch = st.charAt(i);
if (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')
{
continue;
}
st1 = st1 + ch;
}
System.out.println("String without vowels:"+st1);
}
}

Variable Type Description

st String The string entered(and in


uppercase)

k Integer The length of the string

st1 String The string entered without


vowels

i Integer Counter variable

ch Character To extract the characters of the


string

Q48) import java.util.*;


class p48
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter two characters:");
char a = sc.next().charAt(0);
char b = sc.next().charAt(0);
int sum = (int) a + b;
int diff = (int) a - b;
System.out.println("Sum of two characters:"+sum);
System.out.println("Difference of two characters:"+diff);
}
}

Variable Type Description

a Character Character No. 1/First Character

b Character Character No.2/Second


Character

sum Integer Sum of the ASCII value of a and


b

diff Integer Difference of the ASCII value of


a and b

Q49) import java.util.*;


class p49
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a character:");
char a = sc.next().charAt(0);
int x = (int) a;
int y = x + 1;
char b = (char) y;
if(a=='Z')
b = 'A';
if(a=='z')
b = 'a';
System.out.println("The next alphabet is:"+b);
}
}
Variable Type Description

a Character The character entered

x Integer The ASCII value of a

y Integer The ASCII value of the next


character

b Character The next character

[{(+====Programs====+)}]

Bibliography-
★ ICSE IX COMPUTER APPLICATIONS BOOK
★ UNDERSTANDING ICSE COMPUTER APPLICATIONS with BlueJ->Class X
★ Knowledge Boat
★ Javatpoint
★ GeeksforGeeks

/
*______________________THANK___________________________
________________________YOU_________________________*/ ;

You might also like