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?

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!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

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:

Q: Python 3.7.4: Write a loop that reads positive integers from standard input and that terminates when...

A: Program Instructions:The sum is used to calculate the sum of the list.The check variable is used to ...

Q: I dont understand how theyre getting the answers to the output public class MysteryWho {public stati...

A: The output of the given program is:

Q: PLEASE EXPLAIN ALL STEPS: This question has been answered multiple times, clearly by the same tutor,...

A: 1)xz + (xy + ~z)As there are three variables in the above Boolean expression there will be 23 = 8 ca...

Q: Use the pumping lemma to show that the following set is NOT regular: {ww | w => {a,b}*}

A: Pumping Lemma:We can prove this by using pumping lemma which states that L is a regular language if ...

Q: Trace and document every step of execution of the following program. Verify the answer programmatica...

A: Given program after adding printing method is,//Packagepackage package1;//Create a classpublic class...

Q: In MS Access, which kind of values will be accepted by the databasethrough input mask>L0L0L0;0;#A...

A: An input mask in MS-Access contain 3 fields.These fields are separated by semi-colonFirst field spec...

Q: Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: ...

A: To add code segments in the below given program code, so that the code will print "Censored" if user...

Q: PLEASE EXPLAIN ALL STEPSCreate a truth table of the equation:((((Y AND (NOT Z)) OR ((NOT Y) AND Z)) ...

A: Note: In the given equation, the number of opening and closing brackets is not equal. The following ...

Q: CHALLENGE 3.16.2: Alphabetic replace. ACTIVITY Replace any alphabetic character with ' in 2-characte...

A: Program://include the required header files#include <iostream>#include <string>#include ...

Q: How an executable infecting computer virus might append itself to an executable. What changes must i...

A: The VIRUS stands for vital information Resource under siege.The virus may be loaded into your comput...

Q: Problem 2: Using HTML/JavaScript, find and display the number of multiples of a certain number enter...

A: Program:<!--open the html tag--><html> <!--head tag defines the head portion of a doc...

Q: Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "...

A: To create a conditional expression, by adding some code statements to the given program code to chec...

Q: 2. What are the differences between the top-down and bottom-up approaches to information security?Wh...

A: What are the differences between the top-down and bottom-up approaches to information security?Why i...

Q: Suppose you have two tables: EMPLOYEE and EMPLOYEE_1. The EMPLOYEE table contains the records for th...

A: Two tables are given named as EMPLOYEE and EMPLOYEE1. Each table has its records. EMPLOYEE table has...

Q: Find the truth table that describes the following circuit.

A: The given circuit diagram shows operations for each gate. The final Boolean expression found through...

Q: Create reports containing the following details from the database: Q1 How many books are there in th...

A: SELECT category, count(category) AS "numberOfBooks",FROM booksWHERE category='computer'; The above q...

Q: What are the SQL commands to create TABLE BOOK, that includes  both primary and foreign keys, with t...

A: Primary key:A PRIMARY KEY is used to uniquely define every tuple in a table. The PRIMARY KEY imposes...

Q: Hi, I have to code a java program that accepts the ingredients for a recipe in cups and converts to ...

A: Create a class and a class method which will calculate the number of ounce from the number of cups (...

Q: In Python use the Design Recipe to write a function,  count_odds, that consumes a list and two integ...

A: Program Instructions:Write the function header and type contrast of the program.Write description an...

Q: "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the...

A: Program Algorithm-STARTStep1:Import the essential headers.Step2: Declare the main function.Step3: De...

Q: How can I fix that Traceback (most recent call last):  File "C:\Users\Richard Seegerer\Documents\Pyt...

A: Here you are trying to open a file name module.txt in reading only format. You are utilizing a relat...

Q: Describe the activities that occur during project development.

A: Project development is a process in which resources are planned, organized and coordinated to achiev...

Q: How do I use printf to round to tenths for this code?    { public static void main(String[] args) { ...

A: Printf() method is used in java to format the string in output stream. This method takes the string ...

Q: Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, ...

A: To create a conditional expression, by adding some code statements to the given program code. So, th...

Q: Write the pseudocode  and Flowchart for a program that simulates the Magic eight ball game.

A: Pseudocode:Pseudocode is a detailed description of the algorithm of a program that is easier to read...

Q: c. Outline an algorithm for finding the largest key in a B-tree.

A: B-tree is a data structure tree that sorts the data, allows insertion and deletion, searching, and s...

Q: in c++  input file is .txt Write a program that asks for the name of an input file. Then, read all t...

A: In this C++ program, Input is given using file name (xyz.txt) which contains a range of numbers.Outp...

Q: I need help creating a trace table

A: Create a Trace Table and assign all required values according to the code. And if a variable is only...

Q: Design a reasonably efficient algorithm for solving each of the following problems and determine its...

A: Instructions:Initialize 50 state counters Count[] to zero.Traverse the given list of n student recor...

Q: Boolean Logic Draw the truth table for the following functions: F(A,B)=AB+(A+B) F(A,B,C)=AB+BC+...

A: Hey, since there are multiple questions posted, we will answer first question. If you want any speci...

Q: Using C++ 11 Design a class called NumDays. The class’s purpose is to store a value that represents ...

A: Following is the c++ program:This keyword is used to refer to the current instance of class. The pro...

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

A: A Java program that satisfies the given criteria is given below,Program://Import necessary packagesi...

Q: How do I write 1 cup = 8 ounces and then use that to find the total ounces of milk- 2cups +  flour 2...

A: 1 cup is equal to 8 ounces.The total cup is given as 2-cups of milk, 2.66 cups of flour, and 1.5 cup...

Q: Find the truth table that describes the following circuit.

A: The diagram shown below is taken from the given question- 

Q: in python 3.2 Selling a new vehicle pays a salesperson $1500. Selling a used vehicle pays a commissi...

A: Import local function to use currency formatting in the program.prompt user to enter the type of veh...

Q: Python 3.7.4: Write a loop that reads strings from standard input, where the string is either "duck"...

A: Following are some error in given code:There is not requirement to add countWrong expression in whil...

Q: Identify, list, and define the six components of an information system.

A: Information System (IS):Information system is the system that deals with the organisation, storage, ...

Q: The truth table for a Boolean expression is shown below. Write the Boolean expression in sum-of-prod...

A: Answer:Sum of Product (SOP) form:If the input is 1, then write an AND term for each input combinatio...

Q: Question 3

A: Writing the program code in java as in the given question no programming language is specified.This ...

Q: How did Cisco systems solve physical security problems?

A: Cisco is a US-based technology corporation best known for its networking services. As a company that...

Q: Siobhan’s laptop has 8GB of RAM. Her operating system takes up 2GB, andher application programs use ...

A: It also depends that whether the graphic card is installed or not otherwise an 8 Gb of RAM itself is...