-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment_27_StudArray.java
More file actions
84 lines (69 loc) · 1.71 KB
/
Assignment_27_StudArray.java
File metadata and controls
84 lines (69 loc) · 1.71 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
/*
* WAP to accept accept Student name , Marks of 5 subject, calculate the Percentage and display the grade
* Komal Mahale
*/
import java.util.Scanner;
public class Assignment_27_StudArray
{
public static void main(String[] args)
{
Assignment_27_StudArray as= new Assignment_27_StudArray();
as.acceptName();
int arr[]=as.acceptMarks();
as.Percentage(arr);
}
public static String[] acceptName() ///student name
{
int i,size;
Scanner sc=new Scanner(System.in);
System.out.println("Enter number of Student");
size=sc.nextInt(); //size accept from user
String name[]=new String[size];
for(i=0;i<size;i++)
{
System.out.println("Enter name of Student = "+(i+1));
name[i]=sc.next();
}
return name;
}
public static int[] acceptMarks() //student marks
{
int i;
Scanner sc=new Scanner(System.in);
int Marks[]=new int[5];
for(i=0;i<5;i++) ///size by programmer
{
System.out.println("Enter marks of Subject = "+(i+1));
Marks[i]=sc.nextInt();
}
return Marks;
}
public static void Percentage(int Marks[]) //from that marks get the percentage and grade
{
int i,sum=0,per;
for(i=0;i<Marks.length;i++)
{
sum=sum+Marks[i];
}
System.out.println("Sum of all Marks is : " +sum);
per=(sum*100)/500;
System.out.println("Percentage is : " +per+ "%");
//find the grade
System.out.println("grade");
if(per>=90)
{
System.out.println("A ");
}else if(per>80 && per>70)
{
System.out.println("B");
}
else if(per>60 && per>50)
{
System.out.println("C");
}
else
{
System.out.println("Fail");
}
}
}