Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a new project called Lab6 with a main class called YournameLab6 with your name. Write the framework for a menu-based interface. Declare a boolean
- Create a new project called Lab6 with a main class called YournameLab6 with your name.
- Write the framework for a menu-based interface.
- Declare a boolean variable that will be used to determine if a loop should keep going. Initialize it to true.
- Display a welcome message with your name.
- Write a do-while loop that uses the boolean variable as a loop condition. The remaining steps should all appear in the body of the loop, unless stated otherwise.
- Display the following menu:
- Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program
- Read an int from the user and store it in a variable.
- Use that variable as a controlling expression for a switch statement.
- For cases 1 and 2, output the following and exit the switch statement:
- Quiz code goes here
- For cases 3 and 4, output the following and exit the switch statement:
- Table code goes here
- For case 5, set the boolean variable to false and exit the switch statement.
- For the default case output the following and exit the switch statement:
- Invalid choice
- Outside of the loop, display a thank-you message with your name.
- Run your program to see if it works. Here is an example of what the output should look like:
- Welcome to Nicholas Coleman's arithmetic quiz program Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program 1 Quiz code goes here Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program 4 Table code goes here Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program 5 Thank you for using John Leslie's arithmetic quiz program
- Write the code for the arithmetic quizzes.
- Create a named constant that represents the maximum value that you will use for your quizzes and tables. Initialize it to 12.
- Remove the Quiz code goes here output statement.
- Replace it with a do-while statement that repeatedly prompts for a value between 1 and the maximum value constant until the value entered is within the range specified. The output should look something like this:
- Please choose a number between 1 and 12 0 Please choose a number between 1 and 12 13 Please choose a number between 1 and 12 8
- After the do-while statement, initialize a variable to keep track of how many questions the user got right to zero.
- Write a for statement that starts a counter at 1, increments it by 1 at each iteration, and exits when the counter exceeds the maximum value constant.
- In the body of the for statement, do the following
- Display a quiz question of the form NUM OP COUNTER =, where NUM is the number the user chose, OP is either + or * depending on the menu choice, and COUNTER is the counter.
- Read an int from the user and store it in a variable.
- If the user's answer is correct, increment the number of questions the user got right.
- After the for statment, display how many quiz questions the user got right.
- Run your program to see if it works. Here is an example of what the output should look like:
- Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program 1
- Please choose a number between 1 and 12 8 8 + 1 = 9 8 + 2 = 10 8 + 3 = 11 ... 8 + 10 = 18 8 + 11 = 19 8 + 12 = 20 You got 12 right out of 12 Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program 5 Thank you for using John Leslie's arithmetic quiz program
- Write the code for the arithmetic tables.
- Remove the Quiz code goes here output statement.
- Display four spaces followed by a | character.
- Use a for loop to display the column headings on the same line, which should start at one and go up to the maximum value constant. Each column heading should take up four characters.
- On the next line display four - characters followed by a + character.
- Use a for loop to display four - characters under the column headings in the previous line.
- The output so far should look like this:
- | 1 2 3 4 5 6 7 8 910 11 12 ----+------------------------------------------------
- Use a for loop to display each of the row headings on a different line. Each row heading should take up four characters followed by a | character.
- The row headings should look like this:
- 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12|
- Inside of the row heading loop, write a nested for loop that displays a row of the table. Each entry should take up 4 characters and contain the result of adding or multiplying the row and column numbers depending on the menu option chosen by the user.
- Run your program to see if it works. Here is an example of what the output should look like:
- Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program 4 | 1 2 3 4 5 6 7 8 910 11 12 ----+------------------------------------------------ 1| 1 2 3 4 5 6 7 8 910 11 12 2| 2 4 6 8 10 1214 16 1820 22 24 3| 3 6 912 15 1821 24 2730 33 36 4| 4 8 12 16 20 2428 32 3640 44 48 5| 510 15 20 25 3035 40 4550 55 60 6| 612 18 24 30 3642 48 5460 66 72 7| 714 21 28 35 4249 56 6370 77 84 8| 816 24 32 40 4856 64 7280 88 96 9| 918 27 36 45 5463 72 8190 99 108 10| 1020 30 40 50 6070 80 90 100 110 120 11| 1122 33 44 55 6677 88 99 110 121 132 12| 1224 36 48 60 7284 96 108 120 132 144
- Please choose from the following options: 1. Addition Quiz 2. Multiplication Quiz 3. Addition Table 4. Multiplication Table 5. Exit the program 5 Thank you for using John Leslie's arithmetic quiz program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Creating Arithmetic quiz using NetBeans First Create new project in NetBeans IDE class name sa YournameLab6 write the display menu in interface choose from the following options 1 Addition Quiz 2 Mult...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started