Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Concepts used: Random number generation, definite loop, counter variable, modular programming using functions (aka methods), string data (very basic), many-way decision making. This assignment asks

Concepts used: Random number generation, definite loop, counter variable, modular programming using functions (aka methods), string data (very basic), many-way decision making. This assignment asks you to design and implement a program that could be used for testing grade school students knowledge of multiplication tables. The program will operate as follows: 1. The program will greet the student and ask for his/her first name. This name will be read into a string variable and would be used later as part of the report generated. 2. Then the program will present one multiplication table question at a time to the student, using a count controlled loop. The loop will run 10 times, but a named constant should be used to hold that value. The named constant should be used (rather that the literal constant 10) whenever that number is needed for loop control or calculations. The program will generate two random numbers (between 1 and 10) and pose the problem for those numbers like this: What is 7 times 9 ? The program then reads the answer typed by the student and compares it to the answer it calculates and provides one of two possible messages: Your answer is correct! or, Your answer is wrong! The correct answer is 63. 3. Once the student has answered all the problems, the program will display a summary report for the student. The report will include: a. Student's name b. Number of problems attempted c. Number of correct answers given d. Number of incorrect answers given e. A message saying one of the following: i. Congratulations!, You got a perfect score. (if the student has answered all questions correctly) ii. You did all right. (If the student scored at least 80% but less than a perfect score). iii. You pass but should try to do better (if the student scored at least 70% but less than 80%) iv. You really need to study harder. (If the score is less than 70%) 4. It will display the customary sign-off message and exit. Generating the problems In a lab, we used the following statement to generate a value between 1 and 6: face = 1 + rand.nextInt(NUM_FACES); where rand is a random number generator. The rand.nextInt(NUM_FACES) method generates a random integer value between 0 and NUM_FACES 1 (with NUM_FACES = 6), so face will have a value between 1 and 6. So to generate a random integer (an integer value between 1 and 10) we can use the expression 1 + rand.nextInt(10) with appropriate declarations. Program Design The program will use several functions (methods) to divide the problem into parts that can be solved separately. The following functions are required to be present: static boolean oneProblem(int problemNumber) This function will generate a problem, present it to the user, get user's response and provide the feedback (as in Item 2 above). It will return a Boolean value to indicate whether the student solved the problem correctly. This function will be called in a loop by the Page 2 of 6 2018-10-24 main function. The parameter is a problem sequence number sent by the main function (it can be the loop control variable). static void report(String name, int numProbs, int numCorrect) The parameters are: the name of the student, number of problems attempted, number of correct answers. From this information the function will generate the report required (see Item 3 above). You may design and use more functions as you see fit. Structure Diagram The diagram here shows which function(s) call which other function(s). main oneProblem report Output Window Layout You will need 2 lines per problem presented on the output pane. Float the output pane as usual. Make sure the entire output screen shot can fit within a page. See my sample output. I used 11 point font size for the output window. Please make sure that the entire output (including sign-on and sign-off messages) is visible in the screen shot.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago