0% found this document useful (0 votes)
2 views9 pages

Java Programs for Class 8 Students

The document contains a computer project by Anushka Saha, a student from The Aryans School, which includes four Java programs. The programs demonstrate basic functionalities such as a calculator, finding the maximum of three numbers, swapping two numbers, and calculating grades based on average marks. Each program is accompanied by its respective code and an output description.

Uploaded by

Arup SAHA
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)
2 views9 pages

Java Programs for Class 8 Students

The document contains a computer project by Anushka Saha, a student from The Aryans School, which includes four Java programs. The programs demonstrate basic functionalities such as a calculator, finding the maximum of three numbers, swapping two numbers, and calculating grades based on average marks. Each program is accompanied by its respective code and an output description.

Uploaded by

Arup SAHA
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

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

You might also like