import java.util.Scanner;
/**
This Program will ask the user to enter five scores. Than it will display a letter grade for each score and the average score.
Lab 5 page 291 problem 7
This was written by Mario
*/
public class MVAverage&Grade
{//begin class
public static void main (String[]args)
{//begin main method
Scanner keyboard = new Scanner(System.in);
double testScore1;
double testScore2;
double testScore3;
double testScore4;
double testScore5;
System.out.print("Enter your first test score: ");
testScore1 = keyboard.nextInt();
System.out.print("Enter your second test score: ");
testScore2 = keyboard.nextInt();
System.out.print("Enter your third test score: ");
testScore3 = keyboard.nextInt();
System.out.print("Enter your fourth test score: ");
testScore4 = keyboard.nextInt();
System.out.print("Enter your fifth test score: ");
testScore5 = keyboard.nextInt();
keyboard.nextLine();
double average = calcAverage(testScore1,testScore2, testScore3, testScore4, testScore5);
System.out.println("The average is: ");
determineGrade(average);
}
public static double calcAverage(int testScore1, int testScore2, int testScore3, int testScore4, int testScore5)
{
double average = (testScore1 + testScore2 + testScore3 + testScore4 + testScore5) / 5;
return average
}
public static void double determineGrade(double average);
{
if (average>90)
{
System.out.println("You got an A");
}
else if (average>=80)
{
System.out.println("You got a B");
}
else if (average>=70)
{
System.out.println("You got a C");
}
else if (average>=60)
{
System.out.println("You got a D");
}
else if (average<60)
{
System.out.println("You got an F");
System.out.println("The average is: " + average);
}//end class
}//end main method
import java.util.Scanner;
/**
This Program will ask the user to enter five scores. Than it will display a letter grade for each score and the average score.
Lab 5 page 291 problem 7
This was written by Mario Valverde
*/
public class MVAverage&Grade
{//begin class
public static void main (String[]args)
{//begin main method
Scanner keyboard = new Scanner(System.in);
double testScore1;
double testScore2;
double testScore3;
double testScore4;
double testScore5;
System.out.print("Enter your first test score: ");
testScore1 = keyboard.nextInt();
System.out.print("Enter your second test score: ");
testScore2 = keyboard.nextInt();
System.out.print("Enter your third test score: ");
testScore3 = keyboard.nextInt();
System.out.print("Enter your fourth test score: ");
testScore4 = keyboard.nextInt();
System.out.print("Enter your fifth test score: ");
testScore5 = keyboard.nextInt();
keyboard.nextLine();
double average = calcAverage(testScore1,testScore2, testScore3, testScore4, testScore5);
System.out.println("The average is: ");
determineGrade(average);
}
public static double calcAverage(int testScore1, int testScore2, int testScore3, int testScore4, int testScore5)
{
double average = (testScore1 + testScore2 + testScore3 + testScore4 + testScore5) / 5;
return average
}
public static void double determineGrade(double average);
{
if (average>90)
{
System.out.println("You got an A");
}
else if (average>=80)
{
System.out.println("You got a B");
}
else if (average>=70)
{
System.out.println("You got a C");
}
else if (average>=60)
{
System.out.println("You got a D");
}
else if (average<60)
{
System.out.println("You got an F");
System.out.println("The average is: " + average);
}//end class
}//end main method
I COMPILED THE PROGRAM BUT I HAVE SIX ERRORS CAN YOU POINT OUT TO ME WHERE I WENT WRONG.
This post has been edited by pbl: 19 March 2012 - 05:53 PM
Reason for edit:: Please use code tags

New Topic/Question
Reply



MultiQuote



|