-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path41_Control3.java
More file actions
84 lines (77 loc) · 1.91 KB
/
41_Control3.java
File metadata and controls
84 lines (77 loc) · 1.91 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
76
77
78
79
80
81
82
83
84
/*
* Program for Nested if-else
*/
package javaprograms;
import java.util.*;
/**
*
* @author Geeky Keshav
*/
public class Control3
{
public static void main(String args[])
{
int rollno;
String name;
float perc;
int s[]=new int [5];
int total=0;
Scanner obj=new Scanner(System.in);
System.out.print("Enter name of the Student: ");
name=obj.next();
System.out.print("Enter roll no.: ");
rollno=obj.nextInt();
System.out.println("Enter Marks of 5 subjects: ");
for(int i=0;i<s.length;i++)
{
int b=obj.nextInt();
s[i]=b;
total=total+s[i];
}
perc=(total/5);
System.out.println("Name of the Student: "+name);
System.out.println("Roll no. of the Student: "+rollno);
System.out.println("Total marks: "+total);
System.out.println("Percentage: "+perc);
if (perc>=50 && perc<60)
{
System.out.println("Grade: D");
}
else if (perc>=60 && perc<70)
{
System.out.println("Grade: C");
}
else if (perc>=70 && perc<80)
{
System.out.println("Grade: B");
}
else if (perc>=80 && perc<90)
{
System.out.println("Grade: A");
}
else if (perc>=90 && perc<100)
{
System.out.println("Grade: A+");
}
else
{
System.out.println("Grade: Fail");
}
}
}
/****OUTPUT****
run:
Enter name of the Student: keshav
Enter roll no.: 1
Enter Marks of 5 subjects:
96
50
80
75
95
Name of the Student: keshav
Roll no. of the Student: 1
Total marks: 396
Percentage: 79.0
Grade: B
*/