icon

Usetutoringspotscode to get 8% OFF on your first order!

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 don’t 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 user’s answer via cin and compares it against the correct answer. If the user’s 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 user’s 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 user’s 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.

You can leave a response, or trackback from your own site.

Leave a Reply

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 don’t 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 user’s answer via cin and compares it against the correct answer. If the user’s 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 user’s 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 user’s 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.

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

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 don’t 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 user’s answer via cin and compares it against the correct answer. If the user’s 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 user’s 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 user’s 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.

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes