Write a program that allows the user to enter the percentage grade of Ì0 student
ID: 3694292 • Letter: W
Question
Explanation / Answer
import java.io.*;
import java.util.Scanner;
class StudentGrade
{
Public static void main((String args[]))
{
//student array for reading and storing marks
int s[30];
//grade array
char g[12]={ 'A+', 'A', 'A-', 'B+', 'B', 'B-','C+', 'C', 'C-','D+', 'D', 'D-', 'F'};
//here I can not read grades from document please update it
String gd[5]={ "outstanding ","ex ","good ","ad ","ma ","fail "};
//gpa array
int gpa[12]={4.0.4.0.3.7,3.3,3.0,2.7,2.3,2.0,1.7,1.3,1.0,0.7,0.0};
//gpa1 array for calculating respective gpa up on grades
int gpa1[12]={0,0,0,0,0,0,0,0,0,0,0,0,0};
//array for average gpa for respective grade def
int avggpa[5]={0,0,0,0,0,0,0};
int count[5]= {0,0,0,0,0,0};
Scanner in = new Scanner(System.in);
for(i=0;i<30;i++)
{
System.out.println("Enter marks student : "+i);
int s[i] = in.nextInt();
if(s[i]>100&&s[i]<0)
System.out.println("Not correct Grade in percentage Scale ");
elseIf(s[i]>=90&&s[i]<100)
{
System.out.println(g[0]+gpa[0]+gd[0]);
score=score+s[i];
count[0]++;
gpa1[0]= gpa1[0]+gpa[0];
}
elseIf(s[i]>=85&&s[i]<89)
{
System.out.println(g[1]+gpa[1]+gd[1]);
score=score+s[i];
count[1]++;
gpa1[1]= gpa1[1]+gpa[1];
}
elseIf(s[i]>=80&&s[i]<84)
{
System.out.println(g[2]+gpa[2]+gd[1]);
score=score+s[i];
count[1]++;
gpa1[2]= gpa1[2]+gpa[2];
}
elseIf(s[i]>=77&&s[i]<=79)
{
System.out.println(g[3]+gpa[3]+gd[2]);
score=score+s[i];
count[2]++;
gpa1[3]= gpa1[3]+gpa[3];
}
elseIf(s[i]>=73&&s[i]<=76)
{
System.out.println(g[4]+gpa[4]+gd[2]);
score=score+s[i];
count[2]++;
gpa1[4]= gpa1[4]+gpa[4];
}
elseIf(s[i]>=70&&s[i]<=72)
{
System.out.println(g[5]+gpa[5]+gd[2]);
score=score+s[i];
count[2]++;
gpa1[5]= gpa1[5]+gpa[5];
}
elseIf(s[i]>=67&&s[i]<=69)
{
System.out.println(g[6]+gpa[6]+gd[3]);
score=score+s[i];
count[3]++;
gpa1[6]= gpa1[6]+gpa[6];
}
elseIf(s[i]>=60&&s[i]<=62)
{
System.out.println(g[8]+gpa[8]+gd[3]);
score=score+s[i];
count[3]++;
gpa1[8]= gpa1[8]+gpa[8];
}
elseIf(s[i]>=57&&s[i]<=59)
{
System.out.println(g[9]+gpa[9]+gd[4]);
score=score+s[i];
count[4]++;
gpa1[9]= gpa1[9]+gpa[9];
}
elseIf(s[i]>=53&&s[i]<=56)
{
System.out.println(g[10]+gpa[10]+gd[4]);
score=score+s[i];
count[4]++;
gpa1[10]= gpa1[10]+gpa[10];
}
elseIf(s[i]>=50&&s[i]<=52)
{
System.out.println(g[11]+gpa[11]+gd[4]);
score=score+s[i];
count[4]++;
gpa1[11]= gpa1[11]+gpa[11];
}
else{
System.out.println(g[12]+gpa[12]+gd[5]);
score=score+s[i];
count[5]++;
gpa1[12]= gpa1[12]+gpa[12];
}
}//for
System.out.println("Number of students : "+s[].length);
//calculating average gpa for respective grades
avggpa[0]=gpa1[0]/count[0];
avggpa[1]=(gpa1[1]+gpa1[2])/count[1];
avggpa[2]=(gpa1[3]+gpa1[4]+gpa1[5])/count[2];
avggpa[3]=(gpa1[6]+gpa1[7]+gpa1[8])/count[3];
avggpa[4]=(gpa1[9]+gpa1[10]+gpa1[11])/count[4];
avggpa[2]=gpa1[12]/count[5];
for(i=0;i<=5;i++)
{
System.out.println("Average gpa according their grades : "+avggpa[i]);
}
int total= 0;
for(i=0;i<=12;i++)
{
int total= total+gpa[0];
}
System.out.println("Average gpa of all students "+total/13);
}//main
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.