Hello, so here is the program that I am trying to create: write a program to read a collection of exam scores, ranging in value from 0 to 100, until a sentinel of -1 should display the numer of outstanding scores (90-100), the number of satisfactory scores (60-89), and the number of unsatisfactory scores (1-59). It should also prompt the user if they want to see the averages and the percentage of students with satisfactory scores or above for all scores entered. I have gotten the first part done just fine, but I am stuck with the prompt of asking the user if they want to see the averages and percentages. Here is what I have so far:
import java.util.Scanner; //Needed for user input
import java.util.ArrayList; //Needed for array list
//This program calculates a collection of exam scores
//and gives outstanding, satisfactory, unsatisfactory, averages, and passing rates
public class examScores
public static void main(String[] args)
{
//variables to hold exam scores.
int outstandingScore = 0;
int satisfactoryScore = 0;
int unsatisfactoryScore = 0;
int count = 0;
//create keyboard for input
Scanner in = new Scanner(System.in);
//Ask user to input exam score.
System.out.println("Enter a list of exam scores from 0-100 ");
System.out.println("Enter -1 if you are done with your list : ");
int score = in.nextInt();
//While loop for determination of scores
while(score>0)
{
count++;
if(score>=90 && score<=100)
outstandingScore++;
else if(score>=60 && score<=89)
satisfactoryScore++;
else if(score>=1 && score<=59);
unsatisfactoryScore++;
score = in.nextInt();
}//end while
System.out.println("Total number of grades: " + count);
System.out.println("Total number of outstanding scores: " + outstandingScore);
System.out.println("Total number of satisfactory scores: " + satisfactoryScore);
System.out.println("Total number of unsatisfactory scores: " + unsatisfactoryScore);
String input; //To hold keyboard input
double averages = 0; //Average of exam scores
char prompt; //Holds 'y' or 'n'
double total = 0; //Total number of grades
int numInputs = 0; //Total number of scores entered by user
double scores = 0;
//Create a scanner object for keyboard input
Scanner keyboard = new Scanner(System.in);
System.out.println("Do you want to see the averages and passing rates of all scores? ");
System.out.print("Enter Y for yes or N for no: ");
prompt = keyboard.next().charAt(0);
//While loop if prompt is "yes"
if(prompt == 'Y' || prompt == 'y'){
while(prompt == 'Y' || prompt == 'y');
{
numInputs++;
averages = total/numInputs;
if(scores>=100 && scores<=60)
outstandingScore++;
satisfactoryScore++;
if(score>=1 && score<=59);
unsatisfactoryScore++;
score = in.nextInt();
}//end while
}
System.out.println("The average is" + averages);
System.out.println("The percentage of students with satisfactory scores "
+ "or above is: " + count);
}
Everything runs great until I hit "Y" to see the averages, and then it just stops there.....any help is greatly appreciated!