Working with Conditionals and Loops Lab

import static java.lang.System.out; import java.util.Scanner;

public class AverageGrade {

public static void main(String[] args) { double TestScore1;

double TestScore2; double TestScore3; String name1;

Scanner Keyboard = new Scanner(System.in); System.out.print(“Please enter your name:”);

name1 = Keyboard.nextLine(); System.out.println(“Please enter test score1”); TestScore1 = Keyboard.nextInt(); System.out.println(“Please enter test score2”); TestScore2 = Keyboard.nextInt(); System.out.println(“Please enter test score3”); TestScore3 = Keyboard.nextInt();

double average = ((TestScore1 + TestScore2 + TestScore3)/3); out.println(name1);

out.println(“The avarage score of the three tests is: ” + 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”);

}

}

}

Place an Order

Plagiarism Free!

Scroll to Top