Lab6_6.java - Matthew Brannon this program lets a student...

This preview shows page 1 - 2 out of 2 pages.

/* Matthew Brannon 3/30/19 this program lets a student take a math test */ import java.util.*; import java.lang.Math; class Lab6_6 { public static Scanner input = new Scanner(System.in); public static void main(String[] args) { //declarations int counter = 0; String studentName = "No Name"; double averageRight = 0.0; double right = 0.0; int number1 = 0; int number2 = 0; int answer = 0; //get name studentName = inputName(); //displaying the test while (counter < 5) { number1 = getNumber(); number2 = getNumber(); answer = getAnswer(number1, number2, answer); right = checkAnswer(number1, number2, answer, right); counter++; } averageRight = Results(right, averageRight); displayInfo(right, averageRight, studentName); } static double checkAnswer(int number1, int number2, int answer, double right) { if (answer == number1 + number2) { right++; System.out.println("Right"); } else { System.out.println("Wrong"); } return right; } static void displayInfo(double right, double averageRight, String

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture