Question: Lab Assignment 3 COSC - 1 4 3 6 Programming Fundamentals I Java Purpose Java looping and format output implementations Program Specifications: You are to

Lab Assignment 3
COSC-1436 Programming Fundamentals I Java
Purpose
Java looping and format output implementations
Program Specifications:
You are to design a math tutoring program that can be used as a math tutor for a young
student. This program will display a menu allowing user to select an addition, a subtraction,
or a multiplication problem. The last selection on the menu should let user exit the program.
The menu looks like the following:
Math Tutoring Game
1. Addition
2. Subtraction
3. Multiplication
4. Exit the Game
Here are the steps to play the game:
1. The program will prompt the user to enter a selection
2. The program then displays two random numbers between 10 and 50 that are to be
either added, subtracted, or multiplied such as:
36
+27
-------
3. The program should wait for the user to enter the answer. If the answer is correct, a
message of congratulation should be printed. If the answer is incorrect, a message
should be printed showing correct answer.
4. After user has finished the math problem, the program should display the menu
again. This process is repeated until the user selects the choice (4) to exit the
program.
5. Input Validation: If the user selects an item not on the menu, display an error
message and display the menu again.
To Solve this problem, we can identify IPO and develop the Pseudocode.
Input Menu selection
User answer
Processing Use random number to generate 2 numbers between 10 and 50
(inclusive)
Generate math problem from 2 random numbers and user selected
operation
Prompt for user answer and check user answer for correctness
Repeat the process until user select (4) exit the program
Output Display message about users answer
Variables menuSelection, firstNum, secondNum, userAnswer, correctAnswer all
variables are int type
Constants final int MIN =10, MAX =50;
- the range of random number
Random num To generate random number, use Math.random() method
To generate number in range 10-50 inclusive: Use constant MIN and MAX
MIN +(int)(Math.random()*(MAX-MIN+1))
Pseudocode 1. Start a looping structure
2. Display menu (See above menu display)
3. Prompt user to enter menu selection: (1-4)
4. Validate menu selection
5. Display proper message for invalid selection or Exit the Game selection
6. Generate random numbers between 10-50 inclusive
7. Display problem (See above problem display)
8. Prompt user to enter answer
9. Check user answer to see if it is correct and display proper message
10. Repeat the same process until user selects (4) to exit the program
Assignment Instructions:
1. Create a Java program to perform the above tasks. Name the file first_last_a3.py where
first is your first name, and last is your last name. Create a new Java project in Eclipse or
any Java IDE and name it Assignment3, create a class and name it
first_last_mathTutoring.java where first is your first name and last is your last name.
2. Add comments on top of your program to document your code. Include Program
description, your name and date.
3. Use the above pseudocode to help you write Java code.
4. Name your variables clearly and use constants to store fixed information.
5. Make sure your program is easier to read by adding comments and spaces, etc.
6. Submit your Java class file in Canvas for grading.
7. Your program grade will be based on the following criteria:
a. Program code and output accuracy 70%
b. Following program instructions for required identifiers/assignment file name if
there are any 15%
c. Program documentation 10%
d. Program output display 5%
8. You will receive a 0 if you copy others code or let others copy your code. Please refer to
Academy Integrity in course syllabus. Program output is as follows:
Program output: (Test for each menu item)
Math Tutoring Game
1. Addition
2. Subtraction
3. Multiplication
4. Exit the Game
Enter your selection:1
47
+22
--------
Enter your answer:69
Correct!
Math Tutoring Game
1. Addition
2. Subtraction
3. Multiplication
4. Exit the Game
Enter your selection:2
38
-12
--------
Enter your answer:6
Incorrect! the correct answer is: 26
Math Tutoring Game
1. Addition
2. Subtraction
3. Multiplication
4. Exit the Game
Enter your selection:3
19
x 19
--------
Enter your answer:189
ncorrect! the correct answer is: 361
Math Tutoring Game
1. Addition
2. Subtraction
3. Multiplication
4. Exit the Game
Enter your selection:5
Invalid selection
Math Tutoring Game
1. Addition
2. Subtraction
3. Multiplication
4. Exit the Game
Enter your selection:4
Goodbye! Come back again!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!