-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResultPersentage.java
More file actions
75 lines (50 loc) · 2.18 KB
/
ResultPersentage.java
File metadata and controls
75 lines (50 loc) · 2.18 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*Question : Write a program to calculate percentages of a given student in CBSE board exam.
His marks from 5 subjects must be taken as input from the keyboard.(marks are out of 100)
*/
import java.util.Scanner;
public class ResultPersentage {
public static void main(String[] args){
Scanner marks=new Scanner(System.in);
float sub1,avg;
System.out.print("Enter the marks of 1st subject : ");
sub1=marks.nextFloat();
if(sub1<=100){
float sub2,sub3,sub4,sub5;
System.out.print("Enter the marks of 2nd subject : ");
sub2=marks.nextFloat();
if(sub2<=100){
System.out.print("Enter the marks of 3rd subject : ");
sub3=marks.nextFloat();
if(sub3<=100){
System.out.print("Enter the marks of 4th subject : ");
sub4=marks.nextFloat();
if(sub4<=100){
System.out.print("Enter the marks of 5th subject : ");
sub5=marks.nextFloat();
if(sub5<=100){
// calculate the average
avg=((sub1+sub2+sub3+sub4+sub5)/5);
//display the result
System.out.println("You get total "+avg+"% of marks.");
}
else{
System.out.println("Try with right input. ");
}
}
else{
System.out.println("Try with right input. ");
}
}
else{
System.out.println("Try with right input. ");
}
}
else{
System.out.println("Try with right input. ");
}
}
else{
System.out.println("Try with right input. ");
}
}
}