Write a program to be used as a math tutor

Assignment Help C/C++ Programming
Reference no: EM131117430

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.

Reference no: EM131117430

Questions Cloud

The key points-facts presented in the article : Access the GCU Library and select an article that deals with one of the following topics: marketing concept, marketing orientation, market segments, or marketing mix. In a paper of 500-750 words, summarize the article, addressing the following qu..
Implementation of the fibonacci sequences : Provide the c++ implementation of the Fibonacci sequences. Please give the two approaches to the problem
The following regarding a certified public accountant : All of the following regarding a Certified Public Accountant are true except:Must meet education and experience requirements.Must pass an examination.Must exhibit ethical character.May also be a Certified Management Accountant.Cannot hold any cer..
Explain restriction place on state and local government debt : Based on the e-Activities, assess and explain the restrictions placed on state and local government debt in your state. Provide examples to support your answer.
Write a program to be used as a math tutor : Display the menu-Accept user input on the operation to be performed - Display the numbers and accept the users answers from the keyboard on whether they perform addition, subtraction, multiplication or division
Human resource management : You are to work alone on the midterm without any help from anyone. Plagiarism, cheating, and academic dishonesty in any form will result in a grade of F for the course!
Draw a component block diagram : Draw a component block diagram for each of the following feedback control systems.
How can persistently weak currencies be stabilized : How Can Persistently Weak Currencies Be Stabilized. Who Is Correct? Use the Internet to learn more about this issue. Which argument do you support? Offer your own opinion on this issue.
Discuss challenge that you believe the public will encounter : Discuss the major challenges that you believe the public will encounter as a result of the proposed budget. Justify your answer with examples.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Describe the three factors that can be used

What are the main goals of access control and what are the best practices recommended to help in achieving them. Describe the three factors that can be used in authentication and give at least two examples for each.

  Write a program to print the permutation

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation.

  Create and prepare a disk file for records containing struct

Store the account records in the file using the same hashing/rehashing technique used for storing them in an array of structures.

  Create a dictionary and store student

Write a program to create a dictionary and store student id as key and student name as value and display the student id and name. After displaying the dictionary keys and values you should clear the dictionary so that your dictionary becomes empty..

  Implement a rotate function

Write and test the following function: void rotate(int a[], int n, int k); The function "rotates" the first n elements of the array a, k positions to the right.

  Design a modular program that asks the user

A retail company must file a monthly sales tax report listing the total sales for the month, and the amount of state and county sales tax collected. The state sales tax rate is 4 percent and the county sales tax rate is 2 percent. Design a modular..

  The project is to design and write a c11fltk game program

the project is to design and write a c11fltk game program with a graphical user interface. the game is based on

  Display the average height and name of the tallest person

A person has a name and a height in centimeters. Implement a dataset to process a collection of Person objects. Display the average height and the name of the tallest person.

  What are inverse least squares

The data for these calculations are:knowns.xyz contains the spectra of twenty known samples, concentrations.xyz contains the concentrations of a target chemical T in each of the twenty samples, and unknowns.xyz gives the spectra of fifteen more sa..

  Write a program using the class as defined

Write a program using` the class as defined below. Put the class definition in a separate header file, and put all the functions' code in a separate Resource file.

  Write table_avg function to find the average of an array.

Write table_print function to print out a table of size. Print output on one line.table_print(array, size);

  How does using strings like integers alter the o-notation

How does using strings instead of simple types like integers alter the O-notation of operations? Is the ADT given in program 4.7 a first-class ADT? Explain your answer.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd