Professional Documents
Culture Documents
10TH Computer Applications Project 2023
10TH Computer Applications Project 2023
10TH Computer Applications Project 2023
2023-2024
COMPUTER APPLICATIONS
PROJECT
Name:
R.No:
Class:
1
ACKNOWLEDGEMENT
2
JAVA
PROGRAMMING
3
S.N TITLE PAGE NO
o
01 JAVA PROGRAMS
• ASSIGNMENT STATEMENT
• FUNCTION ARGUMENTS
• SERIES
• PATTERN
• READING STATEMENT
• BINARY SEARCH
• CONSTRUCTORS
• FUNCTION OVERLOADING
03 CONCLUSION
04 BIBILOGRAPHY
4
1. Write a java program to find the difference between the simple
interest and compound interest when principle, rate, time are given.
int p,t;
p = 3000;
r = 10;
t = 2;
ci = amt-p;
si = p*r*t/100;
d = ci-si;
5
Variable List:
Name of the Data Purpose/Description
variable Type
p int To store value of principle amount p
t int To store value of time t
r double To store rate and percentage r
si double To calculate and store the simple
interest
ci double To calculate and store the compound
interest
d double To calculate the difference between
simple and compound interest
amt double To store the final amount
OUTPUT:
6
2. Write a java program to find out the area, perimeter and diagonal of
a Rectangle.
public class Rectangle
{
double d;
l = 24;
b = 10;
ar = 1*b;
p= 2*(1+b);
d = Math.sqrt(1*1+b*b);
7
Variable List:
Name of the Data Purpose/Description
variable Type
l int To store value of length l
b int To store value of breadth b
ar int To store value of area ar
p int To store value of perimeter p
d double To calculate and store the value of
diagonal of rectangle d
OUTPUT:
8
3. A computer manufacturing company announces a special offer to
their customers on purchasing laptops and the printers accordingly:
On Laptop : discount-15%
On Printer: discount-10%
Write a Java program to calculate the discount, if a customer
purchases a Laptop and Printer.
public class Computer
{
public static void main (int c, int p)
{
d1 =(double)r1/100*c;
d2 =(double)r2/100*p;
m= c-d1;
n=p-d2;
9
Variable List:
Name of the Data Purpose/Description
variable Type
c int To store price of computer c
p int To store price of printer p
r1 int To store value of computer rate of discount r1
r2 int To store value of computer rate of discount r2
d1 double To calculate and store the value of discount of
computer
d2 double To calculate and store the value of discount of
printer
m double To calculate and store the final amount of
computer
n double To calculate and store the final amount of printer
OUTPUT:
10
4. Write a program to input two unequal numbers. Display the numbers
after swapping their values in the variables without using a third
variable.
Sample Input: a = 76, b = 65
Sample Output: a = 65, b = 76
import java.util.Scanner;
if (firstNum == secondNum)
{
System.out.println("Invalid Input. Numbers are equal.");
return;
}
11
Variable List:
Name of the Data Purpose/Description
variable Type
firstNum int To store the value for first number
secondNum int To store the value for second number
Output
12
5. For every natural number m>1; 2m, m 2-1 and m2+1 form a
Pythagorean triplet. Write a program to input the value of 'm'
through console to display a 'Pythagorean Triplet'.
Sample Input: 3
Then 2m=6, m2-1=8 and m2+1=10
Thus 6, 8, 10 form a 'Pythagorean Triplet'.
import java.util.Scanner;
if (m < 2)
{
System.out.println("Invalid Input, m should be greater than 1");
return;
}
int a = 2 * m;
int b = (int)(Math.pow(m, 2) - 1);
int c = (int)(Math.pow(m, 2) + 1);
System.out.println("Pythagorean Triplets: " + a + ", " + b + ", " + c);
}
}
13
Variable List:
Name of the Data Purpose/Description
variable Type
m int To store the value for first number
a int To store the value for first Triplet number
b int To store the value for second Triplet number
c int To store the value for third Triplet number
OUTPUT:
14
6. A courier company charges differently for 'Ordinary' booking and
'Express' booking based on the weight of the parcel as per the tariff
given below:
import java.util.Scanner;
double charge = 0;
if (wt <= 0)
charge = 0;
else if (wt <= 100 && type == 'O')
charge = 80;
else if (wt <= 100 && type == 'E')
charge = 100;
else if (wt <= 500 && type == 'O')
charge = 150;
else if (wt <= 500 && type == 'E')
15
charge = 200;
else if (wt <= 1000 && type == 'O')
charge = 210;
else if (wt <= 1000 && type == 'E')
charge = 250;
else if (wt > 1000 && type == 'O')
charge = 250;
else if (wt > 1000 && type == 'E')
charge = 300;
Variable List:
Name of the Data Type Purpose/Description
variable
m int To store the value for first number
a int To store the value for first Triplet number
b int To store the value for second Triplet number
c int To store the value for third Triplet number
OUTPUT
16
7. Write a menu driven program to calculate:
import java.util.Scanner;
switch(choice)
{
case 'c':
System.out.print("Enter radius of circle: ");
double r = in.nextDouble();
double ca = (22 / 7.0) * r * r;
System.out.println("Area of circle = " + ca);
break;
case 's':
System.out.print("Enter side of square: ");
double side = in.nextDouble();
double sa = side * side;
System.out.println("Area of square = " + sa);
break;
case 'r':
System.out.print("Enter length of rectangle: ");
17
double l = in.nextDouble();
System.out.print("Enter breadth of rectangle: ");
double b = in.nextDouble();
double ra = l * b;
System.out.println("Area of rectangle = " + ra);
break;
default:
System.out.println("Wrong choice!");
}
}
}
Variable List:
Name of the Data Type Purpose/Description
variable
choice char To enter your choice
r double To enter the value for radius
ca Double To calculate the area of circle
side double To enter the value for side
sa doube To calculate the area of square
l double To enter the value for length
b double To enter the value for breadth
ra double To calculate the area of rectangle
18
OUTPUT
19
8. The relative velocity of two trains travelling in opposite directions is
calculated by adding their velocities. In case, the trains are travelling
in the same direction, the relative velocity is the difference between
their velocities. Write a program to input the velocities and length of
the trains. Write a menu driven program to calculate the relative
velocities and the time taken to cross each other.
import java.util.Scanner;
switch(choice)
{
case 1:
rSpeed = Math.abs(speed1 - speed2);
break;
case 2:
rSpeed = speed1 + speed2;
break;
default:
20
System.out.println("Wrong choice! Please select from 1 or 2.");
}
Variable List:
Name of the Data Type Purpose/Description
variable
choice int To enter your choice
speed1 double To enter the value of velocity for first train
len1 double To enter the value of length for first train
side double To enter the value of velocity for second train
sa double To enter the value of length for second train
l double To enter the value for length
rSpeed double To calculate the relative velocity
time double To calculate the time taken to cross
21
OUTPUT
22
9. Write a program to enter two numbers and check whether they are
co-prime or not.
[Two numbers are said to be co-prime, if their HCF is 1 (one).]
Sample Input: 14, 15
Sample Output: They are co-prime.
import java.util.Scanner;
int hcf = 1;
if (hcf == 1)
System.out.println(a + " and " + b + " are co-prime");
else
System.out.println(a + " and " + b + " are not co-prime");
}
}
23
Variable List:
Name of the Data Type Purpose/Description
variable
a int To enter the value for a
b int To enter the value for b
hcf int To find the factor
OUTPUT
24
10.Write a program to input a number and display it into its Binary
equivalent.
Sample Input: (21)10
Sample Output: (10101)2
import java.util.*;
while(decimal > 0) {
rem = decimal % 2;
binary = binary + (rem * m);
m *= 10;
decimal /= 2;
}
System.out.println("Equivalent binary number: " + binary);
}
}
25
Variable List:
Name of the Data Type Purpose/Description
variable
decimal long To enter the decimal number
binary long To convert the decimal number to binary
m long To multiply the number
rem long To find the remainder
OUTPUT
26
11.Write a program to accept a number and check whether it is a 'Spy
Number' or not. (A number is spy if the sum of its digits equals the
product of its digits.)
import java.util.Scanner;
sum += digit;
prod *= digit;
num /= 10;
}
if (sum == prod)
System.out.println(orgNum + " is Spy Number");
else
System.out.println(orgNum + " is not Spy Number");
}
}
27
Variable List:
Name of the Data Purpose/Description
variable Type
num int To enter the number
digit int To enter the digit
sum int To calculate the sum
prod int To calculate the product
orgNum int To store the original number
OUTPUT
28
12.Using switch statement, write a menu driven program for the
following:
(a) To find and display the sum of the series given below:
S = x1 - x2 + x3 - x4 + x5 - ....................... - x20
(b) To find and display the sum of the series given below:
import java.util.Scanner;
switch (ch)
{
case 1:
System.out.print("Enter the value of x: ");
int x = in.nextInt();
long sum1 = 0;
for (int i = 1; i <= 20; i++)
{
int term = (int)Math.pow(x, i);
if (i % 2 == 0)
sum1 -= term;
else
sum1 += term;
}
System.out.println("Sum = " + sum1);
break;
29
case 2:
System.out.print("Enter the number of terms: ");
int n = in.nextInt();
System.out.print("Enter the value of a: ");
int a = in.nextInt();
int c = 2;
double sum2 = 0;
for(int i = 1; i <= n; i++)
{
sum2 += (1/Math.pow(a, c));
c += 2;
}
System.out.println("Sum = " + sum2);
break;
default:
System.out.println("Incorrect choice");
break;
}
}
}
Variable List:
Name of the Data Purpose/Description
variable Type
ch int To enter the choice
x int To enter the value of x
sum1 long To find the sum
a int To enter the value of a
term int To calculate the term
c int To store the temporary variable
30
OUTPUT
31
13.Write a program to input a set of 20 letters. Convert each letter into
upper case. Find and display the number of vowels and number of
consonants present in the set of given letters.
import java.util.Scanner;
Variable List:
Name of the Data Purpose/Description
variable Type
ch int To enter the characters
vc int To find the vowel characters
cc int To find the consonant characters
32
OUTPUT
33
14.Write a menu driven program to generate the upper case letters
from Z to A and lower case letters from 'a' to 'z' as per the user's
choice.
Enter '1' to display upper case letters from Z to A and Enter '2' to
display lower case letters from a to z.
import java.util.Scanner;
switch (ch)
{
case 1:
for (int i = 90; i > 64; i--)
{
char c = (char)i;
System.out.print(c);
System.out.print(" ");
count++;
34
case 2:
for (int i = 97; i < 123; i++)
{
char c = (char)i;
System.out.print(c);
System.out.print(" ");
count++;
default:
System.out.println("Incorrect Choice");
}
}
}
Variable List:
Name of the Data Purpose/Description
variable Type
ch int To enter your choice
count int To count the characters
35
OUTPUT
36
15.Write a program to input integer elements into an array of size 20
and perform the following operations:
Answer
import java.util.Scanner;
sum += arr[i];
}
37
Variable List:
Name of the Data Purpose/Description
variable Type
arr[] int To enter the numbers
min int To find the smallest number
max int To find the largest number
sum int To find the sum
OUTPUT
38
16.Write a program to input and store roll numbers, names and marks
in 3 subjects of n number of students in five single dimensional
arrays and display the remark based on average marks as given
below:
85 — 100 Excellent
75 — 84 Distinction
60 — 74 First Class
40 — 59 Pass
import java.util.Scanner;
39
s1[i] = in.nextInt();
System.out.print("Subject 2 Marks: ");
s2[i] = in.nextInt();
System.out.print("Subject 3 Marks: ");
s3[i] = in.nextInt();
avg[i] = (s1[i] + s2[i] + s3[i]) / 3.0;
}
System.out.println("Roll No\tName\tRemark");
for (int i = 0; i < n; i++)
{
String remark;
if (avg[i] < 40)
remark = "Poor";
else if (avg[i] < 60)
remark = "Pass";
else if (avg[i] < 75)
remark = "First Class";
else if (avg[i] < 85)
remark = "Distinction";
else
remark = "Excellent";
System.out.println(rollNo[i] + "\t"
+ name[i] + "\t"
+ remark);
}
}
}
Variable List:
Name of the Data Purpose/Description
variable Type
n int To enter the number of students
rollNo int To enter the student roll numbers
Name String To enter the student name
s1,s2,s3 int To enter the subject marks
avg[i] double To find the average
remark String To enter the remarks
40
OUTPUT
41
42
17.Write a program in Java to enter a String/Sentence and display the
longest word and the length of the longest word present in the
String.
Sample Input: “TATA FOOTBALL ACADEMY WILL PLAY
AGAINST MOHAN BAGAN”
Sample Output: The longest word: FOOTBALL: The length of the
word: 8
import java.util.Scanner;
word = "";
}
else
{
word += ch;
}
}
}
43
Variable List:
Name of the Data Purpose/Description
variable Type
str String To enter a word or sentence
len int To find the length of a word or sentence
ch double To find the characters
word String To find the word
OUTPUT
44
18.Write a program using a method Palin( ), to check whether a string
is a Palindrome or not. A Palindrome is a string that reads the same
from the left to right and vice versa.
Sample Input: MADAM, ARORA, ABBA, etc.
import java.util.Scanner;
if (isPalin)
System.out.println("It is a palindrome string.");
else
System.out.println("It is not a palindrome string.");
}
}
45
Variable List:
Name of the Data Type Purpose/Description
variable
s String To enter a word
strlen int To find the length of a word
isPalin boolean To find the given word is Palin or not
OUTPUT
46
19.Design a class to overload a function Joystring( ) as follows:
47
public class StringOverload
{
public void joystring(String s, char ch1, char ch2)
{
String newStr = s.replace(ch1, ch2);
System.out.println(newStr);
}
48
Variable List:
Name of the Data Purpose/Description
variable Type
s String To enter a word
ch1 char To enter a character1
ch2 char To enter a character2
f int To find the first index
l int To find the last index
newStr String To replace a new String
OUTPUT
49
20.Define a class called Student to check whether a student is eligible
for taking admission in class XI with the following specifications:
Member
Purpose
Methods
Marks Eligibility
Average marks 80% or more and less than 90% Science with Hindi
Write the main method to create an object of the class and call all the
member methods.
50
import java.util.Scanner;
return course;
}
51
public static void main(String args[])
{
Variable List:
Name of the Data Purpose/Description
variable Type
name String to store name
mm int to store marks secured in Maths
scm int to store marks secured in Science
comp int to store marks secured in Computer
course String to select the course
n String to enter the name
maths int to enter the marks in Maths
sci int to enter the marks in Science
compSc int to enter the marks in Computer Science
52
OUTPUT
53
21.Write a program to use a class Account with the following
specifications:
Member Methods:
Use another class Calculate which inherits from class Account with the
following specifications:
Member Methods:
55
Variable List:
Name of the Data Purpose/Description
variable Type
acno int To enter the account number
balance float To check the balance
a int To initialize the value for acno
b int To initialize the value for balance
w int To withdraw the amount
d int To deposit the amount
r int To enter the rate
t int To enter the time
si float To calculate simple interest
amt float To calculate amount
x int To assign the value of r
y int To assign the value of t
OUTPUT
56
APPLICATION BASED
MODULE
57
PROGRAM STATEMENT
Program that displays a menu driven
transaction on Bank account,
withdrawing money, deposit money and
many more.
The user enters the choice and
accordingly his/her account details are
displays.
58
//Bank Account Program
import java.io.*;
import java.util.*;
class Account
{
String Name,Password;
int AccNo,Money;
int dd,mm,yy;
public Account(String n,int an,int d,int m,int y,int mon,String p)
{
Name=n;
AccNo=an;
dd=d;
mm=m;
yy=y;
Money=mon;
Password=p;
}
public void displayData()
{
System.out.println(AccNo+"\t"+Name+"\t\t"+dd+"/"+mm+"/"+yy
+"\t"+Money+"\t\t"+Password);
}
}
59
public static InputStreamReader isr=new
InputStreamReader(System.in);
public static BufferedReader x=new BufferedReader(isr);
public static int Ano=1;
public static Account Acc[]=new Account[100];
public static void main() throws IOException
{
int ch=1;
startAccount();
do
{
System.out.println(" Welcome to State Bank ");
System.out.println(" --: OPTION MENU :-- ");
System.out.println(" 1. Create Account ");
System.out.println(" 2. Withdrawl ");
System.out.println(" 3. Deposited ");
System.out.println(" 4. Checking Account ");
System.out.println(" 5. Checking Master ");
System.out.println(" 6. Exit ");
System.out.print( "Enter Your Choice(1-6) : ");
ch=Integer.parseInt(x.readLine());
switch(ch)
{
case 1: createAccount(); break;
case 2: withdrawl(); break;
case 3: deposit(); break;
case 4: checkAccount(); break;
case 5: checkMaster(); break;
}
}while(ch<=5);
}
private static void createAccount() throws IOException
{
60
Calendar c=Calendar.getInstance();
int date=c.get(Calendar.DATE);
int month=c.get(Calendar.MONTH);
int year=c.get(Calendar.YEAR);
String n,p;
int m;
System.out.println("Your Account Number is : "+Ano);
System.out.print("Your Name : ");
n=x.readLine();
System.out.print("Opening Balance : ");
m=Integer.parseInt(x.readLine());
System.out.print("Your Password : ");
p=x.readLine();
Acc[Ano]=new Account(n,Ano,date,month,year,m,p);
Ano++;
}
private static void withdrawl() throws IOException
{
String p;
int no,amt;
System.out.print("Your Account Number : ");
no=Integer.parseInt(x.readLine());
System.out.print("Password : ");
p=x.readLine();
if(no<Ano && p.equals(Acc[no].Password))
{
System.out.println("Welcome "+Acc[no].Name);
System.out.print("Withdrawl Amount : ");
amt=Integer.parseInt(x.readLine());
if(amt<=Acc[no].Money)
Acc[no].Money-=amt;
else
61
System.out.println("Only "+Acc[no].Money+" amount left in
your Account");
}
else
System.out.println("Your are Unauthorized Customer");
}
private static void deposit() throws IOException
{
String p;
int no,amt;
System.out.print("Your Account Number : ");
no=Integer.parseInt(x.readLine());
System.out.print("Password : ");
p=x.readLine();
if(no<Ano && p.equals(Acc[no].Password))
{
System.out.println("Welcome "+Acc[no].Name);
System.out.print("Deposit Amount : ");
amt=Integer.parseInt(x.readLine());
Acc[no].Money+=amt;
}
else
System.out.println("Your are Unauthorized Customer");
}
private static void checkAccount() throws IOException
{
String p;
int no,amt;
System.out.print("Your Account No. : ");
no=Integer.parseInt(x.readLine());
System.out.print("Password : ");
p=x.readLine();
if(no<Ano && p.equals(Acc[no].Password))
62
{
System.out.println("Your Name : "+Acc[no].Name);
System.out.println("Balance Amount : "+Acc[no].Money);
int rate=(Acc[no].Money>=20000)?18:10;
System.out.println("Interest Rate : "+rate+"%");
int interest=Acc[no].Money*rate/100;
System.out.println("Current Balance :
"+(Acc[no].Money+interest));
}
else
System.out.println("Your are Unauthorized Customer");
}
private static void checkMaster()
{
System.out.println("Acc\tName\t\tDate\t\tMoney\t\tPassword");
for(int i=1;i<Ano;i++)
Acc[i].displayData();
}
private static void startAccount()
{
Acc[Ano]=new
Account("Sachin",Ano,date,month,year,500,"ABC"); Ano++;
Acc[Ano]=new
Account("Sourav",Ano,date,month,year,500,"XYZ"); Ano++;
Acc[Ano]=new
Account("Shewag",Ano,date,month,year,500,"MNO"); Ano++;
}
}
63
OUTPUT
64
65
66
67
CONCLUSION
68
BIBLIOGRAPHY
ICSE Understanding Computer
Applications with bluej
www.google.com
69
70