Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ help! A few rules to follow to implement this program: - All functions must be void functions. - No cin or cout statements in

C++ help!

A few rules to follow to implement this program:

- All functions must be void functions.

- No cin or cout statements in int main.

-No global variables. As a consequence, all your functions that need to return a value will have to handle that via pass-by-reference parameters. Implement the following functions:

- void menu(int& usrChoice); Outputs the main menu and then stores the value the user inputted in usrChoice.

- void getNums(int& a, int& b); Asks the user to enter values for a and b and stores the responses in the corresponding variables.

- void add(int a, int b); Adds the values of a and b and outputs the result.

- void sub(int a, int b); Subtracts b from a and outputs the result.

- void mul(int a, int b); Multiplies a by b and outputs the result.

- void div(int a, int b); Divides a by b and outputs the result.

Dont alter the prototypes. I need this program to match the following output and also to be able

to handle different values of a and b according to the menu actions the user chooses.

Sample Output (user input is italicized)

==Main Menu==

1 - add 'a' to 'b'

2 - subtract 'b' from 'a'

3 - multiply 'a' by 'b'

4 - divide 'a' by 'b'

5 - exit

> 1

Enter number a: 4

Enter number b: 5

a + b = 9

==Main Menu==

1 - add 'a' to 'b'

2 - subtract 'b' from 'a'

3 - multiply 'a' by 'b'

4 - divide 'a' by 'b'

5 - exit

> 2

Enter number a: 10

Enter number b: 3

a - b = 7

==Main Menu==

1 - add 'a' to 'b'

2 - subtract 'b' from 'a'

3 - multiply 'a' by 'b'

4 - divide 'a' by 'b'

5 - exit

> 3

Enter number a: 4

Enter number b: 5

a * b = 20

==Main Menu==

1 - add 'a' to 'b'

2 - subtract 'b' from 'a'

3 - multiply 'a' by 'b'

4 - divide 'a' by 'b'

5 - exit

> 4

Enter number a: 101

Enter number b: 20

a / b = 5.05

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions