Write a program that reads student scores, gets the best score, and then assigns
ID: 3632208 • Letter: W
Question
Write a program that reads student scores, gets the best score, and then assigns grades based on the following scheme:Grade is A if score is >= - 10;
Grade is B if score is >= - 20;
Grade is C if score is >= - 30;
Grade is D if score is >= - 40;
The program prompts the user to enter the total number of students, then prompts the user to enter all of the scores, and concludes by displaying the grades.
Cooments throughout the program are appreciated. I give lifesaver if it works and has comments.
Explanation / Answer
Hope this helps, please rate LifeSaver! import java.util.ArrayList; import java.util.Scanner; import java.util.ArrayList; import java.util.Scanner; public class studentScores { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter number of students"); int num = sc.nextInt(); ArrayListscores = new ArrayList(); System.out.println("Enter "+num+" scores"); for(int i =0;i scores.get(j)) { int temp =scores.get(j); scores.set(j, scores.get(j-1)); scores.set(j-1, temp); } else break; } } //assigns the grade values based on the highest score int a = scores.get(scores.size()-1)-10; int b = scores.get(scores.size()-1)-20; int c = scores.get(scores.size()-1)-30; int d = scores.get(scores.size()-1)-40; //runs through the array and tests each score based on the grade for(int i =0; i=a){ System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is A"); } else if(scores.get(i)=b){ System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is B"); } else if(scores.get(i)=c){ System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is C"); } else if(scores.get(i)=d){ System.out.println("Student "+i+" score is "+scores.get(i)+" and grade is D"); } else if(scores.get(i)Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.