Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Grades

/*
* Main.java
*
* Created on September 25, 2007, 4:49 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package grades;
import java.text.*;

/**
*
* @author instructor
*/
public class Main {

/** Creates a new instance of Main */


public Main() {
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
double currentScore = 0;
double totalScore = 0;
int count = 0;
String isContinue = "yes";

while (isContinue.equalsIgnoreCase("yes"))
{
System.out.println("Please enter a new score:");
currentScore = MyInput.readDouble();
totalScore = currentScore + totalScore;
count = count + 1;
if(currentScore >= 90)
{
System.out.println(currentScore + " is an A");
}
else if(currentScore >= 80)
{
System.out.println(currentScore + " is a B");
}
else if(currentScore >= 70)
{
System.out.println(currentScore + " is a C");
}
else if(currentScore >= 60)
{
System.out.println(currentScore + " is a D");
}
else
{
System.out.println(currentScore + " is an F");
} //if else if statement ends here

System.out.println("Continue? (yes/no)");
isContinue = MyInput.readString();
}//while loop ends

double average = totalScore / count;


NumberFormat averageFormat = NumberFormat.getNumberInstance();
averageFormat.setMaximumFractionDigits(2);
averageFormat.setMinimumFractionDigits(2);
System.out.println("The average score is: " + averageFormat.format(average));

} // main() method ends

}//Main class ends

You might also like