Question: Code: DESCRIPTION With this program you are going to design a math practice program for younger users. You will ask the user to enter two

Code:

DESCRIPTION With this program you are going to design a math practice program for younger users. You will ask the user to enter two numbers. Only numbers may be entered. If the user enters a word, the program should disregard the entry and wait for an integer entry. There will not be another prompt if the user enters data other than whole numbers (integers). Here is a sample run: Welcome to Mental Math Practice where you can test your addition, subtraction, multiplication, and division. Enter two integers: asdf 1 2 Enter 1 to add the two numbers. Enter 2 to subtract the second number from the first number. Enter 3 to multiply the two numbers. Enter 4 to divide the first number by the second number. 1 3 Enter 'Quit' to end the program. Enter two integers: 1 2 Enter 1 to add the two numbers. Enter 2 to subtract the second number from the first number. Enter 3 to multiply the two numbers. Enter 4 to divide the first number by the second number. 2 -1 Enter 'Quit' to end the program. Quit BUILD SUCCESSFUL (total time: 22 seconds) Your static methods should accept two integers and return an integer. Do not worry about testing for division by 0 because that won't be one of the tests. Your methods will be named: addNumbers subtract Numbers multiplyNumbers divideNumbers The methods will be static. After each run, the program will ask if the user wishes to quit: Here is the prompt to quit the program: System.out.println("Enter 'Quit' to end the program."); Here are the prompts to read in the choices: System.out.println("Enter 1 to add the two numbers."); System.out.println("Enter 2 to subtract the second number from the first number."); System.out.println("Enter 3 to multiply the two numbers. "); System.out.println("Enter 4 to divide the first number by the second number."); Here is the prompt to read in the two numbers: System.out.println("Enter two integers:"); Here is the welcome prompt: System.out.println("Welcome to *Mental Math Practice* where you can test your addition, subtraction, multiplication, and division."); Use a Scanner to read in the data from the console. Hint: This code will help to skip over added words. while(!scanner.hasNextInt()){ scanner.next(); } 7 8 import java.util.Scanner; 9 10 11 - public class MathTeacher { 12 13 14 - public static int addNumbers(int nl, int n2){ 15 16 } 17 18 - public static int subtract Numbers(int ni, int n2){ 19 20 } 21 22- public static int multiplyNumbers(int nl, int n2){ 23 24 } 25 26 - public static int divideNumbers(int ni, int n2){ 27 28 } 29- 30 * @param args the command line arguments 31 32- public static void main(String[] args) { 33 System.out.println("Welcome to *Mental Math Practices where you can test your addition, subtraction, multiplication, and division."); 34 System.out.println("Enter 1 to add the two numbers."); 35 System.out.println("Enter 2 to subtract the second number from the first number."); 36 System.out.println("Enter 3 to multiply the two numbers."); 37 System.out.println("Enter 4 to divide the first number by the second number."); 38 39 System.out.println("Enter 'Quit' to end the program."); 40 41 } 43 44 } 45 42
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
