You will need to create a math tutor program for elementary school children. It will generate two numbers and then ask the student to give the correct answer to the math problem. You will need to create a flow chart that diagrams your algorithm
Write a program that will do the following:
- Ask the user if they are in first or second grade.
- Generate two whole numbers in the following ranges:
- First Grade= between 1 and 10.
- Second Grade = between 10 and 40.
- Ask the student if they wish to work on addition or subtraction.
- Display the appropriate math equation to the student and ask them to enter the correct answer.
- If the user has asked for subtraction, you must make sure that the smaller number is subtracted from the larger number to ensure there are no negative numbers for the answer.
- The program should ask the user for the answer and then determine if the answer is correct or incorrect.
- You should keep a running total of correct and incorrect answers.
- If the answer is incorrect, give them a chance to enter the correct answer. They are only allowed three chance total to get the correct answer.
- After a correct answer or after the third try, you should display the correct answer.
- Ask the user if they want to run the program again, or quit the program.
- You will need to keep track of the total number tries for all runs.
- You will need to write the total number of incorrect and correct answers to a file, call the file txt.
- Then read in this information calculate the percentage of correct and incorrect answers.
You can assume the following:
- Use the JOptionPane for the data input and output.
- Validate all data
- Only allow for A for addition and S for subtraction
- Don’t allow negative numbers for an answer
- Use the printf command to output the data.
- Parse data as necessary
Your program must be written using standard programming practices and run without errors. You need to apply the appropriate data types for the expected variables. All output needs to look as depicted above. All calculation must be done correctly.
Items to upload to Moodle:
- The .java file
- The txt file
Items to hand in:
- The flow chart of the algorithm.