Use Java for the following 1) (Assign grades) Write a program that reads student
ID: 663603 • Letter: U
Question
Use Java for the following
1) (Assign grades) 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 best Grade is B if score is best ; Grade is C if score is best ; Grade is D if score is best ; Grade is F otherwise. 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. Here is a sample run: Enter the number of students: 4 Enter 4 scores: 40 55 70 58 Student 0 score is 40 and grade is C Student 1 score is 55 and grade is B Student 2 score is 70 and grade is A Student 3 score is 58 and grade is B
2) (Multiples) Write a method isMultiple that determines, for a pair of integers , whether the second integer is a multiple of the first. The method should take two integer arguments and return true if the second is a multiple of the first and false otherwise. [Hint: Use the remainder operator .] Incorporate this method into an application that inputs a series of pairs of integers (one pair at a time) and determines whether the second value in each pair is a multiple of the first.har()
Explanation / Answer
//according to your requirement grades based on the following scheme: Grade is A if score is best Grade is B if score is best ; Grade is C if score is best ; Grade is D if score is best ; Grade is F otherwise.
// the grades are assignes according to best grade
//if you want to assign them according to score range ie marks above 70 is A grade then change if condition to
//use command if (grades[i] >= 70) grade = 'A'; and so on....
=======================Program Begins=========================
public static void grades(){
Scanner in = new Scanner(System.in);
System.out.println("How many grades would you like to enter? "); //input how many grades user would like to enter
int q = in.nextInt();
int[] grades = new int[q];
int best = 0;
for (int counter = 0; counter < q; counter++)
{ //user enters # of grades they requested to enter
System.out.println("Enter your grades: ");
double grade = in.nextInt();
grades[counter] = grade;
int best = 0;
}
for (int i = 0; i < grades.length; i++) {
if (grades[i] > best)
best = grades[i];
}
for (int i = 0; i < grades.length; i++) {
if (grades[i] >= best - 10)
grade = 'A';
else if (grades[i] >= best - 20)
grade = 'B';
else if (grades[i] >= best - 30)
grade = 'C';
else if (grades[i] >= best - 40)
grade = 'D';
else
grade = 'F';
output += "Student " + i + " score is " + grades[i] +
" and grade is " + grade + " ";
}
/* Display the result */
System.out.println(output);
System.exit(0);
} // End of method main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.