Write a program to call 5 functions to determine Letter grades of 20 students. T
ID: 670154 • Letter: W
Question
Write a program to call 5 functions to determine Letter grades of 20 students. The main function should call following functions: A function called introduction explain the program and its requirements. A function called getdata to read the student ID, Exam1, Exam2, and Exam3 scores from the keyboard. A function called studentaverage to calculate the Average of exams for each student. A function called lettergrade to determine the letter grade for each student. A function called printdata to print the information for all students. This include student Id, Exam1, Exam2, Exam3, Average, and Grade. You must create parallel arrays for student ID, exam1, exam2, exam3, average, and grade The exam average is: average = (Exam1 + Exam2 + Exam3)/3. The letter grade is determined by: 90-100 A 80-89 B 70-79 C 60-69 D 59 and less F in c++
Explanation / Answer
Not any particular language mention so I am using java
class Student
{
String array[20][5];
String Sid;
String marks1;
String marks2;
String marks3;
String average;
String grade;
void getData()
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Sid=br.readLine();
marks1=br.readLine();
marks2=br.readLine();
marks3=br.readLine();
}
void average()
{
average=((Integer.parseInt(s.marks1)+Integer.parseInt(s.marks2)+Integer.parseInt(s.marks3))/3).toString();
}
void lettergrade()
{
if(Integer.parseInt(s.average)>90 &&Integer.parseInt(s.average)<=100)
s.grade=A;
else if(Integer.parseInt(s.average)>=80 &&Integer.parseInt(s.average)<=89)
s.grade=B;
else if(Integer.parseInt(s.average)>=70 &&Integer.parseInt(s.average)<=79)
s.grade=C;
else if(Integer.parseInt(s.average)>60 &&Integer.parseInt(s.average)<=69)
s.grade=D;
else
s.grade=F;
}
void print(int i)
{
System.out.println("Student " + (i+1));
System.out.println("Marks1" + s.marks1);
System.out.println("Marks1" + s.marks2);
System.out.println(""Marks1" + s.marks3);
System.out.println("average " + s.average);
System.out.println("grade " + s.grade);
}
public static void main(String[]args)
{
for(int i=0;i<20;i++)
{
Student s=new Student();
s.getData();
array[i][0]=s.Sid;
array[i][1]=s.marks1;
array[i][2]=marks2;
array[i][3]=marks3;
s.average();
s.print();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.