Create a new file (in Dev C++) and save it as lab10_XYZ.cpp (replace XYZ with your initials). In Lab 2, you created a menu for a simple calculator program. In Lab 6, you added some functionality based on the user selection. In Lab 7, you added some functionality for a main program loop and input validation. In this lab, you will create some general purpose functions to offload some of the tasks in main(). Write functions for: displaying a message (void) display menu and return user selection (int) prompt user for a number and return the number (int) adding (void) subtracting (void) multiplying (void) dividing (void) checking if number is 0 (bool) Prototypes must be written for each function. Definitions for each function may be in any order, after main(). Call functions as needed. Remember that functions can call other functions. If you see the same code repeating in different places, there is a good chance that a function could be used to simplify things. By now, you've gone through the thought process of how the main program loop works. Since the assignment is more about the use of functions, I'm providing a good bit of the main() function below. You will still need to determine arguments to use and how the parameters will be structured within each function. You may use the code below, or modify your existing code to use functions. SAMPLE MAIN PROGRAMint main(){bool flag = true;int choice;displayMessage("Hello, welcome to the calculator program!\n\n");while (flag){choice = menu();switch (choice){case ADD: add(); break;case SUB: subtract(); break;case MUL: multiply(); break;case DIV: divide(); break;case EX: flag = false; break;default: displayMessage("\nSorry, that was invalid\n"); break;}}displayMessage("\n\nProgram exiting. Goodbye!\n");return 0;} LANGUAGE IS C++ Simple as possible PLEASE!

Question

Create a new file (in Dev C++) and save it as lab10_XYZ.cpp (replace XYZ with your initials).

  • In Lab 2, you created a menu for a simple calculator program.
  • In Lab 6, you added some functionality based on the user selection.
  • In Lab 7, you added some functionality for a main program loop and input validation.

In this lab, you will create some general purpose functions to offload some of the tasks in main().

Write functions for:

  • displaying a message (void)
  • display menu and return user selection (int)
  • prompt user for a number and return the number (int)
  • adding (void)
  • subtracting (void)
  • multiplying (void)
  • dividing (void)
  • checking if number is 0 (bool)

Prototypes must be written for each function. Definitions for each function may be in any order, after main().

Call functions as needed. Remember that functions can call other functions. If you see the same code repeating in different places, there is a good chance that a function could be used to simplify things. By now, you've gone through the thought process of how the main program loop works. Since the assignment is more about the use of functions, I'm providing a good bit of the main() function below. You will still need to determine arguments to use and how the parameters will be structured within each function. You may use the code below, or modify your existing code to use functions.

SAMPLE MAIN PROGRAMint main()
{
bool flag = true;
int choice;

displayMessage("Hello, welcome to the calculator program!\n\n");

while (flag)
{
choice = menu();
switch (choice)
{
case ADD: add(); break;
case SUB: subtract(); break;
case MUL: multiply(); break;
case DIV: divide(); break;
case EX: flag = false; break;
default: displayMessage("\nSorry, that was invalid\n"); break;
}
}

displayMessage("\n\nProgram exiting. Goodbye!\n");
return 0;
}

LANGUAGE IS C++

Simple as possible PLEASE!

Expert Answer

Want to see the step-by-step answer?

See Answer

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

See Answer
*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.
Tagged in
EngineeringComputer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: Simplify the following functional expressions using Boolean algebra and its identities. List the ide...

A: (a) F(x,y,z) = y(x’ + (x + y)’)

Q: I want to see how one can add 80 elements into an array without manually entering in each element.  ...

A: Given,The name of the first array is numberArray1 and the size of the array is 80.The name of the se...

Q: PLEASE EXPLAIN ALL STEPS: simplify the boolean equations: xz + (xy + ~z) ~xyz + yz + x~y

A: 1)xz + (xy + ~z)For simplifying the Boolean expression, use Karnaugh Map and follow the below steps-...

Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...

A: Program:  import java.util.Scanner; public class AtmSimDoLoop{public static void main(String[] args)...

Q: Please explain how you solve the follwing problem:

A: a) CHAIN set for each variable:CHAIN(S) = {B, C, A}CHAIN(A) = {A}CHAIN(B) = {B}CHAIN(C) = {C, A}

Q: Active Directory metadata describes the actual Active Directory data, not the Active Directory datab...

A: Active Directory:The Microsoft Technology used to manage computers and the other devices in a networ...

Q: Explain pipelining and think of a real-world analogy to the concept as if you were explaining it to ...

A: Pipelining:Pipelining is the technique of dividing a sequential process into sub-processes, each sub...

Q: for C++ write a progam for the greatest common divisor of integers x and y is the largest integer th...

A: program to find the greatest common divisor of x and y.if x is 0 then answer is y.if y is 0 then the...

Q: in python program4_4.pyWrite a program that prompts the user to enter a series of strings, but with ...

A: Program code: