## Become a good journalist and a doctor Essay

11. Write a program that allows the user to enter students’ names followed by their test scores and outputs the following information (assume that maximum number of students is 50):
a. The average score.
b. Names of all students whose test scores are below the average, with an appropriate message. c. Highest test score and the name of all students having the highest score.
Use two arrays to store the student names and scores respectively and then manipulate the array contents.
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;

We Will Write a Custom Essay Specifically
For You For Only \$13.90/page!

order now

// 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();

// 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();
// 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

x

Hi!
I'm Larry!

Would you like to get a custom essay? How about receiving a customized one?

Check it out