0% found this document useful (0 votes)
16 views

Computer Project

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Computer Project

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

New Doon Blossoms School, Dehradun Affiliated by

Council for the Indian School Certificate Examination


PROJECT ON: Computer Applications
Submitted By: Rakshit Kumar Jha UID/ADM NO. : 773
Class : IX SESSION : 2020-21
Acknowledgement

It gives me a great pleasure to have an


opportunity here to acknowledge and express
my humble gratitude to the ones who helped me
in making the project. Although it is impossible
to thank everyone individually, I remember all
those who have guided me in completion of the
project. I sincerely acknowledge a deep
gratitude for the valuable guidance, suggestions
and generous help extended to me by my
subject teacher in the project.

-Rakshit Kumar Jha


Certificate
This is to certify that Rakshit Kumar Jha
of Class IX under the guidance of
Mr. Sachin Gairola has prepared a
project on the Computer Applications
within the syllabus of ICSE.

....Teachers Signature.....
INDEX
Serial Number Programs Page Number
1. Based on Input 1 to 10

2. Based on Calculation 11 to 20

3. Based on If……else 21 to 30

4. Based on Switch case 31 to 40

5. Based on Iliteration 41 to 60
5 JAVA PROGRAMS BASED ON INPUT

1) A PROGRAM TO INPUT THREE SIDES OF TRIANGLE.

import java.util.Scanner;
class TriangleSide
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter first side of tiangle");
int a = sc.nextInt();
System.out.print("Enter second side of tiangle");
int b = sc.nextInt();
System.out.print("Enter third side of tiangle");
int c = sc.nextInt();
}
}
Output

In this program a, b, c, are the sides of the


triangle.
Using scanner class we can input the
desired sides.
2) Program to input sides of rectangle.
import java.util.Scanner;
class TrianglePerimeter
{
public static void main(String[] args)
{
Scanner sc=new
Scanner(System.in);
System.out.print("Enter sides of rectangle");
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
}
}
OUTPUT
In this program ‘a’ , ‘b’ ‘c’ and ‘d’ are the sides of
rectangle.
Scanner class help us to input the sides of
rectangle with our desire.
3. Write a Program to input numbers.

import java.util.*;
class number
{
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
System.out.print("Enter first number- ");
int a= sc.nextInt();
System.out.print("Enter second number- ");
int b= sc.nextInt();
System.out.print("Enter third number- ");
int c= sc.nextInt();
}
}
OUTPUT

Enter first number- 2


Enter second number- 4
Enter third number- 6
4. Write a Program to input age of three persons.

import java.util.*;
class age
{
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
System.out.print("Enter first age- ");
int a= sc.nextInt();
System.out.print("Enter second age- ");
int b= sc.nextInt();
System.out.print("Enter third age- ");
int c= sc.nextInt();
}
}
OUTPUT

Enter first age- 2


Enter second age- 4
Enter third age- 6
5. Write a Program to input height of three
persons.
import java.util.*;
class height
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter first height- ");
float a= sc.nextFloat();
System.out.print("Enter second height- ");
float b= sc.nextFloat();
System.out.print("Enter third height- ");
float c= sc.nextFloat();
}
}
OUTPUT

Enter first height- 5.2


Enter second height- 6.0
Enter third height- 4.9
5 JAVA PROGRAMS BASED ON
Calculations
1) A PROGRAM TO INPUT THREE SIDES OF TRIANGLE AND
CALCULATE PERIMETER
import java.util.Scanner;
class TrianglePerimeter
{
public static void main(String[] args)
{
int p;
Scanner sc=new
Scanner(System.in);
System.out.print("Enter three sides of tiangle");
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
p=(a+b+c);
System.out.print("Perimeter of Triangle is:"+p);

}
}
Output

Enter three sides of tiangle


3
4
5
Perimeter of Triangle is:12
2. Write a program to enter sides of rectangle and find perimeter.

import java.util.Scanner;
class RectanglePerimeter
{
public static void main(String[] args)
{
int p;
Scanner sc=new
Scanner(System.in);
System.out.print("Enter sides of rectangle");
int l=sc.nextInt();
int b=sc.nextInt();
p=(2*l+2*b);
System.out.print("Perimeter of Rectangle is:"+p);

}
}
Output

Enter sides of rectangle4


5
Perimeter of Rectangle is:18
3. Write a program to enter the sides of square and find perimeter.

import java.util.Scanner;
class SquarePerimeter
{
public static void main(String[] args)
{
int p;
Scanner sc=new
Scanner(System.in);
System.out.print("Enter sides of square");
int s=sc.nextInt();
p=(4*s);
System.out.print("Perimeter of Square is:"+p);

}
}
Output

Enter sides of square9


Perimeter of Square is:36
4. Write a program to calculate the area of rectangle

import java.util.Scanner;
class Rectanglearea
{
public static void main(String[] args)
{
int a;
Scanner sc=new
Scanner(System.in);
System.out.print("Enter sides of rectangle");
int l=sc.nextInt();
int b=sc.nextInt();
a=(l*b);
System.out.print("Area of rectangle is:"+a);

}
}
Output
Enter sides of rectangle3
4
Area of rectangle is:12
5. Write a program to calculate simple interest.

import java.util.Scanner;
class SimpleInterest
{
public static void main(String[] args)
{
int I;
Scanner sc=new
Scanner(System.in);
System.out.print("Enter Princilpe");
int p=sc.nextInt();
System.out.print("Enter Rate");
int r=sc.nextInt();
System.out.print("Enter Time");
int t=sc.nextInt();
I=(p*r*t/100);
System.out.print("Simple Interest is:"+I);

}
}
Output

Enter Princilpe 1000


Enter Rate3
Enter Time4
Simple Interest is:120
5 Java programs based on if...else
1. Wap to input any number and check whether it is even or
odd
import java.util.*;
class program
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n;
System.out.println("Enter any number");
n=sc.nextInt();
if(n%2==0)
System.out.println("Even number");
else
System.out.println("odd Number");
}
}
Output

We used scanner class. If our choice


is '2' the output will be even and if
our choice is 3 the output will be
odd.
2. Wap to input two numbers number and print the greater
number.
import java.util.*;
class program
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b;
System.out.println("Enter two numbers");
a=sc.nextInt();
b= sc.nextInt();
if(a>b)
System.out.println("Greater number is"+a);
else
System.out.println("greater number is"+b);
}
}
Output

Using scanner class and if..else we


can find the output as per the
numbers.
3. Wap to input three numbers number and print the greater
number.
import java.util.*;
class program
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,c;
System.out.println("Enter three numbers");
a=sc.nextInt();
b= sc.nextInt();
c=sc.nextInt();
if(a>b && a>c)
System.out.println("Greater number is"+a);
else if(b>a && b>c)
System.out.println("greater number is"+b);
else if(c>a && c>b)
System.out.println("Greater number is"+c);
else
System.out.println("All numbers are equal");
}
}
Output

Enter three numbers


A
B
C
We will get the greatest number
4. Wap to input three angels of a triangle and check whether
it is valid triangle ot not.
import java.util.*;
class program
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,c;
System.out.println("Enter three angels");
a=sc.nextInt();
b= sc.nextInt();
c=sc.nextInt();
if(a+b+c==180)
System.out.println("valid triangle");

else
System.out.println("Not a valid Triangle");
}
}
Output
Enter three angles
A
B
C
The function will calculate whether
it is valid triangle or not
And we will get the output as
valid triangle
Or
not a valid triangle
5. Wap to input three angels of a triangle and check whether it
is right angle triangle or not.
import java.util.*;
class program
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,c;
System.out.println("Enter three angels");
a=sc.nextInt();
b= sc.nextInt();
c=sc.nextInt();
if(a==90 || b==90 || c==90)
System.out.println("Right angle triangle");

else
System.out.println("Not a right angle Triangle");
}
}
Output
Enter three angles
A
B
C
The function will calculate whether it is
right angle triangle or not
And we will get the output as
Right angle triangle
Or
Not a right angle triangle
5 Java programs based on switch case
1. Write a program to enter the dys of week and press 1 to 7 to find the
day.
import java.util.*;
class menudriven
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int ch;
System.out.println("Enter your choice");
ch=sc.nextInt();
switch(ch)
{
case 1:System.out.println("Sunday");
break;
case 2:System.out.println("Monday");
break;
case 3:System.out.println("Tuesday");
break;
case 4:System.out.println("Wednesday");
break;
case 5:System.out.println("Thursday");
break;
case 6:System.out.println("Friday");

break;
case 7:System.out.println("Saturday");
break;
default: System.out.println("wrong choice");
}
}
}

Output
Enter your choice
3
Tuesday
Enter your choice
5
Thursday
2. Write a program to input two numbers press 1 to find sum and press 2
to find product.
import java.util.*;
class menudriven
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int ch,a,b,c;
System.out.println("Enter two numbers");
a=sc.nextInt();
b=sc.nextInt();
System.out.println(“Press 1 to print sum”);
System.out.println(“Press 2 to print product”);
System.out.println("Enter your choice");
ch=sc.nextInt();
switch(ch)
{
case 1:c=a+b;
System.out.println("Sum is"+c);
break;
case 2:c=a*b;
System.out.println("Product is"+c);
break;
default:
System.out.println("wrong choice");
}
}
}

Output
Enter two numbers
3
3
Press 1 to print sum
Press 2 to print product
Enter your choice
1
Sum is6
3. Write a menu driven to input two numbers . press 1 to print the greater
number. press 2 to print the smaller number
import java.util.*;
class menudriven
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int ch,a,b,c;
System.out.println("Enter two numbers");
a=sc.nextInt();
b=sc.nextInt();
System.out.println(“press 1 to print greater”);
System.out.println(“press 2 to print smaller number”);
System.out.println("Enter your choice");
ch=sc.nextInt();
switch(ch)
{
case 1:if(a>b)
System.out.println("Greater umber is"+a);
else
System.out.println("Greater number is"+b);
break;
case 2:
if(a<b)
System.out.println("Smaller number is"+a);
else
System.out.println("Smaller number is"+b);
break;
default:
System.out.println("wrong choice");
}
}
}

Output
Enter two numbers
5
7
press 1 to print greater
press 2 to print smaller number
Enter your choice
1
Greater number is7
4. Write a program to calculate mathematical functions.
import java.io.*;
public class Mathematics
{
public static void main(String args[])throws IOException
{
int n,ch;
InputStreamReader read =new InputStreamReader(System.in);
BufferedReader in =new BufferedReader(read);
System.out.println("Enter 1 to find the Natural Log");
System.out.println("Enter 2 to find absolute value");
System.out.println("Enter your choice 1 or 2");
ch=Integer.parseInt(in.readLine());
switch (ch)
{
case 1:
System.out.println("Enter a number");
n=Integer.parseInt(in.readLine());
System.out.println("The Natural Log of" +n + "is "+Math.log(n));
break;
case 2:
System.out.println("Enter a number");
n=Integer.parseInt(in.readLine());
System.out.println("The absolute value of" +n + "is "+Math.abs(n));
break;
default:
System.out.println("Wrong Choice!!");
}
}
}

Output
Enter 1 to find the Natural Log
Enter 2 to find absolute value
Enter your choice 1 or 2
1
Enter a number
5
The Natural Log of 5 is 1.6094379124341003
5. Write a program to calculate the square root and cube root .
import java.io.*;
public class Square_Cube_Root
{
public static void main(String args[])throws IOException
{
int n,ch;
InputStreamReader read =new InputStreamReader(System.in);
BufferedReader in =new BufferedReader(read);
System.out.println("Enter 1 to find the Square root");
System.out.println("Enter 2 to find cube root");
System.out.println("Enter your choice 1 or 2");
ch=Integer.parseInt(in.readLine());
switch (ch)
{
case 1:
System.out.println("Enter a number");
n=Integer.parseInt(in.readLine());
System.out.println("The Square root of" +n + "is "+Math.sqrt(n));
break;
case 2:
System.out.println("Enter a number");
n=Integer.parseInt(in.readLine());
System.out.println("The cube root" +n + "is "+Math.cbrt(n));
break;
default:
System.out.println("Wrong Choice!!");
}
}
}

Output
Enter 1 to find the Square root
Enter 2 to find cube root
Enter your choice 1 or 2
1
Enter a number
4
The Square root of4is 2.0
5 Programs based on Iliteration
1. Write a program to print your name thirty times
import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i; for(i=1;i<=30;i++)
{
System.out.println("Rahul");
}
}
}
Output
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
Rahul
And till 30 times
2. Write a program to print all natural numbers from 1 to 10.

import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i;
for(i=1;i<=10;i++)
{
System.out.println(i);
}
}
Output
1
2
3
4
5
6
7
8
9
10
3. Write a program to print all natural numbers 20 to 1.

import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i;
for(i=20;i>=1;i--)
{
System.out.println(i);
}
}
}
Output
20 4
19 3
18 2
17 1
16
15
14
13
12
11
10
9
8
7
6
5
4
4. Write a program to print all even numbers from 2 to 20.

import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i;
for(i=2;i<=20;i+=2)
{
System.out.println(i);
}
}
}
Output
2
4
6
8
10
12
14
16
18
20
5. Write a program to print all even numbers from 20 to 2.

import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i;
for(i=20;i>=2;i-=2)
{
System.out.println(i);
}
}
}
Output

20
18
16
14
12
10
8
6
4
2
6. Write a program To find the product of first five natural numbers.

import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i,f=1;
for(i=1;i<=5;i++)
{
f=f*i;
}
System.out.println("Product is"+f);
}
}
Output

We Will get the output as: Product is 120


7. Write a program To find the sum of all even numbers till 20.
import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i,s=0;
for(i=2;i<=20;i+=2)
{
s=s+i;
}
System.out.println("Sum is"+s);
}
}
Output

We will get the output as: Sum is 110


8. Write a program to input any number and find its factorial.

import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i,n,f=1;
System.out.println("enter any number");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
f=f*i;
}
System.out.println("Factorial is"+f);
}
}
Output

enter any number


3

Factorial is6

enter any number


9

Factorial is362880
9.Write a program to input any number and print its factors.

import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i,n,f=1;
System.out.println("enter any number");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
if(n%i==0)
System.out.println(i);
}
}
}
Output

enter any number


5

1
5
10. Write a program to input any number and find the sum of all factors
of a number.
import java.util.*;
class ARR
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i,n,sum=0;
System.out.println("enter any number");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
if(n%i==0)
sum=sum+i;
}
System.out.println("sum of all factors are"+sum);
}
}
Output
enter any number
5
sum of all factors are6

enter any number


6
sum of all factors are12
Bibliography
I have used the following resources to take
information for making the project:
*Understanding Computer Applications with
Blue-J.(Evergreen publications)
*www.Google.com
*www.Brainly.in

You might also like