Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program Requirements ( Implement these requirements in main . c file ) In the following information, numbered points describe a core requirement of the program,
Program Requirements Implement these requirements in mainc file
In the following information, numbered points describe a core requirement of the program, and bullet
points in italics are additional details, notes and hints regarding the requirement. Ask your tutor if
you do not understand the requirements or would like further information.
Print a welcome message, and then prompt the user to select a difficulty by entering or
Use a loop to reprompt the user until a valid response or is entered. Once a difficulty has
been selected, print a message confirming the selected difficulty and set variables as follows:
If Easy was chosen... lives maxnum and questions
If Medium was chosen... lives maxnum and questions
If Hard was chosen... lives maxnum and questions
lives represents how many incorrect answers are permitted, maxnum represents the largest
number used when generating a question, and questions represents the number of questions.
Set a score variable to and then enter a loop that repeats questions times.
score will be used to keep track of how many questions the user has answered correctly.
The body of this loop must...
Print which question the user is up to out of the total number of questions, as well as
how many lives that have remaining, egQuestion of You have lives remaining.
Print life remaining rather than lives remaining if lives is
If the current question is not the final question of the test, use the askquestion
function detailed below to generate and administer a question involving numbers between
and maxnum.
If the current question is the final question of the test, print Challenge question! and use
the askquestion function user defined to generate and administer a question
involving numbers between maxnum and maxnum multiplied by
eg The challenge question on Easy difficulty would use numbers between and
If the askquestion function returns a value of True, add one to the score variable.
Otherwise, subtract from the lives variable. If the lives variable is now print Out
of lives, game over! and immediately end the test proceeding to Requirement
Print a test complete message, followed by a message that displays the users score out of
questions, and what percentage that represents, egYou scored
Round the percentage value to the nearest whole number.
Print the users grade, based upon their percentage. The grades are High Distinction
Distinction Credit Pass and Fail
Semester CSP Assignment Page
The askquestion Function
There are two points in Requirement where the program must generate and administer a question.
This is a selfcontained task consisting of a number of steps, with the only difference being the
minimum and maximum numbers to use. As such, it is ideal to create a function for this task.
You must create a function named askquestion that receives two parameters:
minimum an integer representing the smallest number to use in the question
maximum an integer representing the largest number to use in the question
The function should generate two random integers between minimum and maximum, and then
randomly select a mathematical operator of either or for easy and medium difficulties, and
xmultiplication or division for hard difficulty. It should use these
values to display a question, egWhat is and prompt the user for their answer.
If the user answers correctly, the function should print Correct and return the Boolean value of
True. Otherwise, the function should print Incorrect and the correct answer, and return False.
The code that you design and write to implement this function is up to you, but you may find it useful
to use the following C function:
The rand function, to generate random numbers within a range
The definition of the function should be at the start of the program, and it should be called where
needed in the program. Revise Module and if you are uncertain about defining and using
functions, and be sure to implement it so that it receives and returns values exactly as described
above.
Ensure that the function does exactly what is specified above and nothing more it is important to
adhere to the stated specifications of a function, and deviating from them will impact your marks.
Create additional functions max in your program to achieve a modular solution.
Semester CSP Assignment Page
Additional Features Implement these additional features on top of basic
program requirements in a separate mainadditions.c file
Below are some additional features that you need make to the program to further test and
demonstrate your prog
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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