This project is based on Value Returning Methods. So here is my code:
[highlight = Java]
import java.util.Scanner;
public class HW8_1
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner (System.in);
double a;
double b;
double c;
double d;
double e;
double total;
String average = "";
double calcAverage = 0.0;
System.out.println("Please enter five test scores:");
System.out.println("Test score #1:");
a = keyboard.nextDouble();
System.out.println("Test score #2:");
b = keyboard.nextDouble();
System.out.println("Test score #3:");
c = keyboard.nextDouble();
System.out.println("Test score #4:");
d = keyboard.nextDouble();
System.out.println("Test Score #5:");
e = keyboard.nextDouble();
total = calcAverage(a,b,c,d,e);
average = determineGrade(calcAverage);
System.out.println("Your letter grade is " + average);
}
public static double calcAverage (double num1, double num2, double num3, double num4, double num5)
{
return (num1 + num2 + num3 + num4 + num5) / 5;
}
public static String determineGrade (double total)
{
if (total >= 90)
{
return "A";
}
else if (total >= 80 && total <= 89)
{
return "B";
}
else if (total >= 70 && total <= 79)
{
return "C";
}
else if (total >= 60 && total <= 69)
{
return "D";
}
else if (total >= 0 && total <=59)
{
return "F";
}
return total;
}
}
[/highlight]
The assignment asks for the user to enter 5 different grades and spit out returns on two things.. the average of the 5 scores and a letter grade based on the average.
When I compile, the letter grade doesn't show up. I've been changing the code left and right but I'm all out of ideas.
What am I doing wrong?