-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent2.java
27 lines (27 loc) · 983 Bytes
/
student2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.Scanner;
public class student2{
int rollNo; int total=0;
double percentage;
String Name;
static Scanner sc = new Scanner(System.in);
void getInfo(){
System.out.println("Enter student roll number, Name, and PCMBE Marks in order");
rollNo = Integer.parseInt(sc.nextLine());
Name = sc.nextLine();
for (int i=1; i<=5; i++)
total += Integer.parseInt(sc.nextLine());
}
void calcPercentage(int totalMarks){
percentage = (double)totalMarks/500*100;
}
void display(){
System.out.println("------------------------");
System.out.println("Name: "+Name+"\nRoll Number: "+rollNo+"\nTotalMarks: "+total+"\nPercentage score: "+percentage);
System.out.println("------------------------");
}
public static void main(String[] args) {
student2 s1 = new student2();
s1.getInfo(); s1.calcPercentage(s1.total); s1.display();
sc.close();
}
}