Display the menu-accept user input on the operation to be


Question 1

Write a program to be used as a math tutor for a young student. The program should display a menu allowing the user to select addition, subtraction, multiplication or division. The final selection on the menu should allow the user to quit and exit the program. Each of modules, Addition, Subtraction, Multiplication and Division should be separate functions called from Main.

1. Display the menu-Accept user input on the operation to be performed

2. Generate 2 random numbers from 1-20 - Pass the random numbers to each function as arguments.

3. If user selects division, ensure the divisor is not zero.

4. Display the numbers and accept the users answers from the keyboard on whether they perform addition, subtraction, multiplication or division

5. Compute the correct answer with your program. Compare the users answer to the answer you calculated in your program.

6. If the user enters the correct answer, display the message
Congratulations..You are Correct

7. If the user enters the incorrect answer, display the message
Incorrect..The correct answer is...
display the correct answer.

8. The program should display the menu again, until the user ends the program by choosing to quit

------------------------------------------------------------------------------------------------------------------------------------
- ***must include a header file and prototype file ( example function addit/devideit etc etc)***
- must loop while and/or do while will work but they need to be able to go from division to addition etc etc and so forth
- if you use need vector use array instead
- the answers will be output on the screen not a separate file
- please be willing to make changes to the code as to either correct errors or if anything used wasnt learned
- any further questions please feel free to ask
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
incomplete and error filled answer given
------------------------------------
#include //Header Declaration
#include
#include //Used for a better random number generator
#include //Used for a better random number generator
using namespace std;

int ans1, num1, num2; // declare num1 and num2
int choice; // variable choice

void mainmenu(); // Main menu
void addition(int rand1, int rand2); // addition function
void subtraction(int rand1, int rand2); // subtraction function
void multiplication(int rand1, int rand2); // multiplication function
void division(int rand1, int rand2); // division function
bool start = true; // start

int main()
{
if (start = true)
mainmenu ();
else if (start = false);
system("pause");
return 0;
}
void addition(int rand1, int rand2) // perform addition.
{
/* Initialize some var's and set equal to our passed values */
int random1 = rand1;
int random2 = rand2;

cout
cin >> ans1;

cout
if( ans1 == ( random1 + random2 ) )
{
cout }
else
{
cout }

mainmenu();
}
void subtraction(int rand1, int rand2) //do subraction function.
{
/* Initialize some var's and set equal to our passed values */
int random1 = rand1;
int random2 = rand2;

cout
cin >> ans1;

cout
if( ans1 == ( random1 - random2 ) )
{
cout }
else
{
cout }

mainmenu();
}
void multiplication(int rand1, int rand2) //do multiplication function.
{
/* Initialize some var's and set equal to our passed values */
int random1 = rand1;
int random2 = rand2;

cout
cin >> ans1;

cout
if( ans1 == ( random1 * random2 ) )
{
cout }
else
{
cout }

mainmenu();
}
void division(int rand1, int rand2) // do division function.
{
/* Initialize some var's and set equal to our passed values */
int random1 = rand1;
int random2 = rand2;

cout
cin >> ans1;

cout
if( ans1 == ( random1 / random2 ) )
{
cout }
else
{
cout }

mainmenu();
}
void mainmenu()
{

/* Advamced Random Number Generation (Better-Results) */
int random1, random2;
time_t seconds; /* Declare variable to hold seconds on clock. */
time( &seconds ); /* Get value from system clock and place in seconds variable. */
srand( ( unsigned int ) seconds ); /* Convert seconds to a unsigned integer. */

random1 = rand() % (20 - 1 + 1) + 1;
random2 = rand() % (20 - 1 + 1) + 1;


/* Standard Random Number Generation (Ok-Results) */
//int random1 = rand() % 20+1; // Random number will start at 0 so add one
//int random2 = rand() % 20+1; // Random number will start at 0 so add one

cout cout
/*main menu options */
cout cout cout cout cout
cin >> choice; //ask user to enter selection, places it in int choice

switch (choice)
{
case 1: addition(random1, random2);
break;
case 2: subtraction(random1, random2);
break;
case 3: multiplication(random1, random2);
break;
case 4: division(random1, random2);
break;
case 5:
(start = false);
int main(); cout break;
default:
cout cin.clear();
cin.sync();
mainmenu();

Question 2

During winter when it is very cold, typically, everyone would like to know the windchill factor, especially, before going out. Meteorologists use the following formula to compute the windchill factor, W:

https://i.imgur.com/LbWONlb.png (img link to forumla )

where V is the wind speed in miles per hour and T is the temperature in degrees Fahrenheit. Write a program that prompts the user to input the wind speed, in miles per hour, and the temperature in degrees Fahrenheit.

The program then outputs the windchill factor. Your program must contain at least two functions: one to get the user input and the other to determine the windchill factor.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Display the menu-accept user input on the operation to be
Reference No:- TGS01495388

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)