I just got my java project (beginner). . and its like this
Output:
What is my grade in Java?
(part where you input a grade)
My grade in Math?
(input math grade)
(the next screen shows the grades i input, gets the average, then the shout out of my grade)
JAVA 100
MATH 100
___________
-->AVERAGE 100
YOU ARE GREAT
(then shows this)
DO YOU WANT TO TRY AGAIN [Y/N]?(input)
I got only 1 problem when all is running bellow AVERAGE 100 got odd result
Error:
YOU ARE GREAT
DO YOU WANT TO TRY AGAIN [Y/N]?YOU ARE GREAT
DO YOU WANT TO TRY AGAIN [Y/N]?(input)
My Code:
import java.util.Scanner;
class Test {
public static void main(String[] args){
Scanner myScanner = new Scanner(System.in);
average = 0;
String answer = "Y";
while (answer == "Y"){
System.out.println("What is my grade in Java?");
jgrade = myScanner.nextDouble();
System.out.println("\n");
System.out.println("My grade in Math? ");
mgrade = myScanner.nextDouble();
System.out.print("JAVA ");
System.out.println(jgrade);
System.out.print("Math ");
System.out.println(mgrade);
System.out.println("____________");
average = (jgrade + mgrade) / 2;
System.out.print("AVERAGE ");
System.out.println(average);
while (average < 101);
if (average >=95){
System.out.println("YOU ARE GREAT");
else if (average >=90)
System.out.println("YOU GOT GOOD GRADES");
else if (average >=85)
System.out.println("NOT BAD FOR A BEGINNER");
else if (average >=80)
System.out.println("YOUR A BEGINNER");
else if (average >=75)
System.out.println("YOU PASSED! CONGRATULATIONS");
else if(average >=50)
System.out.println("PERFECT ABSENT");
System.out.print("DO YOU WANT TO TRY AGAIN [Y/N]? ");
answer = myScanner.nextline();
}//if
}//while
}
}
Please reply asap T_T