In this program we will read student details like name, roll number, marks in math, physics and English then print the student details with name, roll number, inputted marks, total marks and percentage.
Mike
101
88 77 99
Name=Mike
Roll Number=101
Marks=88 77 99
Total=264
Percentage=88.0
shiva
9130713
65 75 68
Name=shiva
Roll Number=9130713
Marks=65 75 68
Total=208
Percentage=69.33333333333333
Mariya
38579398
78
89
76
Name=Mariya
Roll Number=38579398
Marks=78 89 76
Total=243
Percentage=81.0
WARNER
8001234
75 45
34
Name=WARNER
Roll Number=8001234
Marks=75 45 34
Total=154
Percentage=51.333333333333336
Tags JAVA languagesSubscribe Our Newsletter
import java.io.*;
ReplyDeleteimport java.util.Scanner;
public class TestClass {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
String name=sc.nextLine();
int roll=sc.nextInt();
int m1=sc.nextInt();
int m2=sc.nextInt();
int m3=sc.nextInt();
System.out.println("Name="+name);
System.out.println("Roll Number="+roll);
System.out.println("Marks="+m1+" "+m2+" "+m3);
int total=(m1+m2+m3);
System.out.println("Total="+total);
double percentage=(double)total/3;
System.out.println("Percentage="+percentage);
}
}