14 May THIS QUESTION IS RELATED TO C++ (PROGRAMMING LANUAGE) AND WILL BE COMPLETED BY USING VISUAL STUDIO SOFTWARE. A WRITER WHO HAS QUALIFICATION IN COMPUTER RELATED TO C++ PROGRAMMING CAN DO THIS QUESTIOIN IN VISUAL STUDIO.
C++
This question is related to C++ (programming lanuage) and will be completed by using visual studio software. A writer who has qualification in computer related to C++ programming can do this questioin in visual studio.
Ensure that your comments are detailed enough to indicate your design process, since you do not have to submit an assignment file in addition to your code.
Question 1.
Your task is to write a program to repeatedly generate random multiplications to quiz the user, and keep score.
Generate the two multiplicands (e.g. 6 and 7) and compute the correct answer (42). Then ask the user for his/her answer, and compare it to the correct answer. If the user gets it right, increment the total score. Display the score as a fraction (e.g. 5/8 correct) and a percentage, displayed to the nearest percent (e.g. 63%). Continue generating questions as long as the user indicates he/she would like to keep playing.
Constraint: you must include functions in your program. Include at least these 4 functions, fitting the supplied prototypes:
1. A function called NewRandomNumber() that receives an integer n (e.g. 10), and returns a new random number between 2 and n. We dont want to make questions like 1×3 or 0x8 because these are too easy.
int NewRandomNumber(int n);
Your function should make use of rand() (part of the cstdlib library) . rand() generates a pseudo-random integer between 1 and 32767. use % and + to convert this integer to an integer between 2 and n.
2. A function MakeQuestion() to create the question to ask the user. This function should call NewRandomNumber() twice to make two new random numbers; it should figure out what the answer should be, and then return the two numbers and the answer. MakeQuestion()needs to know about n so it can tell NewRandomNumber() what kind of numbers to make. Because this function needs to return 3 values, it should use reference parameters.
void MakeQuestion(int n, int& a, int& b, int& atimesb);
3. A function UserAnswerIsCorrect() that uses the two operands and the correct
answer which were generated in MakeQuestion() and presents the question to the user via cout. It then receives the users answer via cin and compares it against the correct answer. If the users answer is correct, it returns True. Otherwise, it returns False.
bool UserAnswerIsCorrect(int a, int b, int correctAnswer);
4. A function PrintScore() that receives the total number of questions the user has
answered correctly, as well as the total number of questions, and computes and displays the users score as a fraction and as a percentage.
void PrintScore(int numCorrect, int numAsked);
At the beginning of the program, the user should be able to choose their difficulty by entering a number. For example, if the user enters “4”, the computer should only generate questions up to 4 times 4. If the user enters “12”, the program should generate questions up to 12 times 12.
Your program should also generate a log file of important data, such as the generated question, the users response, and the cumulative score. This log should be a comprehensive record of the program run, but should not be a duplication of every user interaction. Further, you must format this log file nicely. For example:
QUIZ PROGRAM LOG FILE
User name: John Smith
Difficulty: 8
Question Response Cumul. Score
============== ======== ==============
3 * 5 = 15 15 1/1 (100%)
8 * 2 = 16 16 2/2 (100%)
6 * 9 = 54 45 2/3 (66%)
END OF SESSION
Make sure to fully test your program, and show your testing in your log file. Justify your choice of test cases in your comments.
BONUS: Research and make use of a random number seed, so that the random numbers are different every time the program is run.
MORE BONUS: Research the clock() function in the <ctime> library (http://www.cplusplus.com/reference/ctime/clock/) to implement a timer to measure how long the user takes to answer the question. Maybe you want to reward the user for quick answers, and insult the user if they take too long. Maybe the user has to answer within 10 seconds. Maybe you want to display a countdown timer to show the user how long they have left. Maybe you want to track the time in the log and compare to the last time the user saw the question to see if they are improving. Be creative.
SUPER AMAZING BONUS: Keep a file with a list of users and their score, and each time a user opens the program and enters their name, check against the file to see if they have played before. If they have, continue their score from where they left off.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
