import java.util.Scanner; // for double formatting import java.text.DecimalForma
ID: 3657336 • Letter: I
Question
import java.util.Scanner; // for double formatting import java.text.DecimalFormat; public class StudentScore { //--------------------------------------------------------- // Calculate student score and basic report //--------------------------------------------------------- public static void main(String[] args) { // an array of double to store student's score double [] studentscore = new double[50]; // an array of String object to store student name String [] studentname = new String[50]; double studentavg = 0.0, sumscore = 0.0, averagescore = 0.0, highestscore =0.0; // index int i = 0, j = 0, k = 0, counter = 1; Scanner readname = new Scanner(System.in); Scanner readscore = new Scanner(System.in); // prompt for inputs: Student name and score System.out.println("Enter student name and score, 'Q' & 0 to stop: "); // read and store student name and score for 1st input... studentname[i] = readname.nextLine(); studentscore[i] = readscore.nextDouble(); // read and store next student name and score do { i++; counter++; System.out.println("Enter student name and score, 'Q/q' & 0 to stop: "); studentname[i] = readname.nextLine(); studentscore[i] = readscore.nextDouble(); // until the Q or q and 0 are entered... } while(((studentname[i].compareTo("Q") != 0) || (studentname[i].compareTo("q") != 0)) && (studentscore[i] != 0)); // formatting the double output to two decimal places DecimalFormat fmt = new DecimalFormat("0.##"); // some cosmetic formatting... System.out.println("=================REPORT===================="); System.out.println("Student Name Score"); System.out.println("------------ -----"); // set initial value of the highest score to the 1st array element // and then compare 1 by 1 in the for loop... highestscore = studentscore[0]; for(k=0;k<=i-1;k++) { // print all the student names and their respective scores System.out.println(studentname[k]+" "+fmt.format(studentscore[k])); // summing up all the score for average calculation sumscore = sumscore + studentscore[k]; // determining the highest score if(highestscore < studentscore[k]) highestscore = studentscore[k]; } // calculate class average score System.out.println(); System.out.println("The number of student is " + (counter-1)); averagescore = sumscore / (counter-1); System.out.print("The average score for this class is " + fmt.format(averagescore)); // some cosmetic formatting... System.out.println(); System.out.println("================================================"); System.out.println("Below The Average Students! Work Harder! "); System.out.println("================================================"); System.out.println("Student Name Score"); System.out.println("------------ -----"); // list down all the below average students for(k=0;k<=i-1;k++) { if(studentscore[k] < averagescore) System.out.println(studentname[k] + " " + fmt.format(studentscore[k])); } // some cosmetic formatting... System.out.println("================================================"); System.out.println("Top Scorer Student! Congratulation!"); System.out.println("================================================"); System.out.println("Student Name Score"); System.out.println("------------ -----"); // list down all the highest mark students for(k=0;k<=i-1;k++) { if(studentscore[k] == highestscore) System.out.println(studentname[k] + " " + fmt.format(studentscore[k])); } } }Explanation / Answer
If student?s grade is greater than or equal to 90 Display ?A? else If student?s grade is greater than or equal to 80 Display ?B? else If student?s grade is greater than or equal to 70 Display ?C? else If student?s grade is greater than or equal to 60 Display ?D? else Display ?F? Also below link will help you find complete solution. https://docs.google.com/viewer?a=v&q=cache:clCu6GmDk9EJ:www.comscigate.com/ppt/DeitelSimplyJava/simplyjava1_06.ppt+psuedocode+for+double+formatting+import+java.text.DecimalFormat%3B+public+class+StudentScore+%7B&hl=en&pid=bl&srcid=ADGEESiPP5QQ6fHeLDulbbF95ooToFNuKX_OGj5t2HRBG-gLyvhh4HqDtK0LaHMYDG_TWghyMasL_MTqyQm-LnsV2VJpzqzjKHZMaiq8fykevoPsDrp3EjGFC9iHWvNca3kdZyB3mhLq&sig=AHIEtbSS00wjRLB5SDZcv3kjPyBcXK1vjg
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.