import java.util.Scanner; public class main { public static void main(String args[]){ Scanner scan = new Scanner(System.in); System.out.println("This program is built to generate 2 digit multiplication"); System.out.println("The numbers can range from 10-99"); System.out.println("Enter the number of equations to work on below:"); int amount = scan.nextInt(); int a = 0; int correct = 0; int wrong = 0; int score = 0; while(a < amount){ int x = 10 + (int)(Math.random()*89); int y = 10 + (int)(Math.random()*89); int z = x * y; System.out.println(x + "x " + y); int answer = scan.nextInt(); if(answer == z){ System.out.println("Correct!"); correct++; score += 5; } else{ System.out.println("Wrong!"); wrong++; score -= 9; } amount--; } System.out.println("\nSTATISTICS:"); System.out.println("Correct: " + correct); System.out.println("Wrong: " + wrong); System.out.println("Score: " + score); } }
How could I create a Stopwatch that begins once the user enters the number of equations they would like to use, then have that stopwatch end once the final question is answered. Then finally be able to print out the amount of time the stopwatch was running.