Design and Develop a java program to read marks of a student and print the total and average of marks using scanner class.

Program Code:
import java.util.*;
import java.io.*;
class Student
{
public static void main(String args[])
{
Scanner sc=new Scanner (System. in);
int marks[]=new int[5];
float total=0,avg;
for (int i=0;i<5;i++)
{
System.out.println (“Enter marks”);
marks[i]=sc.nextInt();
}
for(int i=0;i<5;i++)
{
total+=marks[i];
}
avg=total/5;
System.out.println(“ Total is”+total);
System.out.println(“ Avg is”+avg);
}
}

Output:
Enter marks
55
Enter marks
66
Enter marks
77
Enter marks
88
Enter marks
99
Total is 385.0
Avg is 77.0
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: