Computer project
Name : Anushka Saha
Class : 8D
Roll no. 6
School : The Aryans School
Program 1
Calculator program
import [Link].*;
class Calculator
public static void main()throws IOException
InputStreamReader isr=new InputStreamReader([Link]);
BufferedReader br=new BufferedReader(isr);
[Link]("Enter two numbers");
int a= [Link]([Link]());
int b= [Link]([Link]());
int c= a+b;
int d= a-b;
int e= a*b;
int f= a/b;
[Link]("Sum of two numbers"+c);
[Link]("Difference of two numbers"+d);
[Link]("Multiplication of two numbers"+e);
[Link]("Division of two numbers"+f);
}
OUPUT OF THE PROGRAM
Program 2
Print maximum number among three numbers
import [Link].*;
class Maximum
public static void main(String args[])throws IOException
InputStreamReader isr=new InputStreamReader([Link]);
BufferedReader br=new BufferedReader(isr);
[Link]("Enter three numbers");
int a= [Link]([Link]());
int b=[Link]([Link]());
int c=[Link]([Link]());
if(a>b && a>c)
[Link]("First number is maximum");
else if(b>a && b>c)
[Link]("Second number is maximum"+b);
else
[Link]("Third number is maximum"+c);
}
OUTPUT OF THE PROGRAM
Program 3
Swapping two numbers using third variable
import [Link].*;
class Interchange
{
public static void main()throws IOException
InputStreamReader isr=new InputStreamReader([Link]);
BufferedReader br=new BufferedReader(isr);
[Link]("Enter the two numbers");
int a=[Link]([Link]());
int b=[Link]([Link]());
int c=a;
a=b;
b=c;
[Link](a);
[Link](b);
Output of the program
Program 4
Grade program using if else condition
import [Link].*;
class Grade
public static void main()throws IOException
{
InputStreamReader isr=new InputStreamReader([Link]);
BufferedReader br=new BufferedReader(isr);
[Link]("Enter the marks of 4 subjects ");
int a=[Link]([Link]());
int b=[Link]([Link]());
int c=[Link]([Link]());
int d=[Link]([Link]());
double av=(a+b+c+d)/4.0;
if(av>80)
[Link]("Grade A");
else if(av>=61 && av<=80)
[Link]("Grade B");
else if(av>=41 && av<=60)
[Link]("Grade C");
else
[Link]("Grade D");
Output of the program