Question

In: Computer Science

As simple as possible. Please In C++ Computers are playing an increasing role in education. Write...

As simple as possible. Please

In C++ Computers are playing an increasing role in education.
Write a program that will help an elementary school student learn multiplication. Use rand() to
produce two positive single digit integers. It should then display a question in the following format
(assume 6 and 7 are randomly generated):
How much is 6 * 7?
The student then types the answer. Your program checks the student’s answer. If it is correct, print
“Very good!” If the answer is wrong, print “No. Please try again.” and then let the student
try the same question again repeatedly until the student finally gets it right. If the number of
incorrect exceeds five, the program should leave the question, display “Let’s try another
one!” and ask a different question. After every answer, the program should ask whether the user
wants to continue the program and based on the response, the program should be continued or
terminated.

Solutions

Expert Solution

C++ code:

#include<iostream>
using namespace std;

int main(){

while(true){

int number1 = rand()%10;
int number2 = rand()%10;
int ans = number1*number2;
int student_ans;

char quit = 0;

cout<<"How much is "<<number1<<" * "<<number2<<"?\n";
cin>>student_ans;

if (student_ans == ans){
cout<<"Very good!\n";
cout<<"Do you want to continue? (Press q to quit or any other key to continue)\n";
cin>>quit;

if (quit == 'q' || quit == 'Q')
return 0;
}
else{
for(int i=0;i<5;i++){
cout<<"No. Please try again\n";
cout<<"Do you want to continue? (Press q to quit or any other key to continue)\n";
cin>>quit;

if (quit == 'q' || quit == 'Q')
return 0;
cout<<"Enter your answer: ";
cin>>student_ans;

if (student_ans == ans){
cout<<"Very good!\n";

cout<<"Do you want to continue? (Press q to quit or any other key to continue)\n";
cin>>quit;

if (quit == 'q' || quit == 'Q')
return 0;

break;
}
}

if (student_ans != ans)
cout<<"Let’s try another one!";

}
}
return 0;
}

Output:


Related Solutions

Week 10 - Please write in C++ as simple as possible RRCC has a schedule of...
Week 10 - Please write in C++ as simple as possible RRCC has a schedule of courses that includes: Subject (like: CSC) Course Number (like: 119) Section (like: 802) Credits (like: 3) Title Days (like: MW) Time (like 8:00am-9:15am) Instructor From this schedule information above create a class called RRCC_schedule (with a .cpp file and a .h file). Look at each item above and determine the type of data that will go into the variable. Then create a UML with...
Please write in C++ as simple as possible I want you to create a Book Class...
Please write in C++ as simple as possible I want you to create a Book Class for a bookstore. I am not going to tell you what variables should go into it, that is for you to figure out (but you should have at least 5+). And then you must create a UML with all the variables and methods (like: the getters and setters, a default constructor, and a constructor that takes all the variables and finally the printValues() )....
Write in c++ as simple as possible In a right triangle, the square of the length...
Write in c++ as simple as possible In a right triangle, the square of the length on one side is equal to the sum of the squares of the lengths of the other two sides.  Write a program that prompts the user to enter the length of three sides of the tringle (as doubles) and the outputs a message indication whether the triangle is a right triangle.  You should split this into two functions (but only one .cpp file).  One function is main()...
Wireless technology is rapidly evolving, and is playing an increasing role in the lives of people...
Wireless technology is rapidly evolving, and is playing an increasing role in the lives of people throughout the world. Analyze the potential issues and problems associate with wireless technology. plz answer me quickly. SUBJECT : TELECOMMUNICATION SWITCHING AND NETWORK.
write in C++ as simple as possible please and thanks don't use header file <bits/stdc++.h> All...
write in C++ as simple as possible please and thanks don't use header file <bits/stdc++.h> All programs work with binary numbers which are powers of 2 (2, 4, 8, …).  Write a program that will have a user enter a number (n) less than 10,000. Then have the program put each power of 2 (int) into an array up to and possibly including the number n. This means you don't know at the start how large the array will be, so...
USE C++ and please keep program as simple as possible and also comment so it is...
USE C++ and please keep program as simple as possible and also comment so it is easy to understad Create a structure called time. Its three members, all type int, should be called hours, minutes, and seconds. Write a program that prompts the user to enter a time value in hours, minutes, and seconds. This should be in 12:59:59 format. This entire input should be assigned first to a string variable. Then the string should be tokenized thereby assigning the...
Write the simple shell in C language. Please show some outputs.
Write the simple shell in C language. Please show some outputs.
USE C language :- The use of computers in education is referred to as computer-assisted instruction...
USE C language :- The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use the rand function to produce two positive one-digit integers. The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask...
(In C++) Write a class that will represent a card in a standard deck of playing...
(In C++) Write a class that will represent a card in a standard deck of playing cards. You will need to represent both the suit (clubs, diamonds, hearts or spades) as well as the rank (A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2) of each card. Write methods to • Initialize the deck of cards • Perform a perfect shuffle In a perfect shuffle, the deck is broken exactly in half and rearranged so that...
Please explain how these figures are generated as simple as possible
Source    SS    df    MS    F    p-value A    5.0139    1    5.0139    100.28    0 B    2.1811    2    1.0906    21.81    .0001 AB    0.1344    2    0.0672    1.34    .298 Error    0.6000    12    0.0500        Please explain how these figures are generated as simple as possible
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT