Question

Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program.

-Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings.

-Use Microsoft Visio 2013 for developing your flowchart.

-Adherence to the ANSI C++  required

-Do not use <stdio.h> and <conio.h>.

-Do not use any #define in your program.

-No goto statements allowed.

Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu.

The menu options are:

Help SubIntegers   MulIFloats   Quit             

Once the menu item is selected and validated, the program will proceed with processing that selection as explained below.

If the user selects h or H, the program uses function help to display a help screen and tells the user how the program operates and what is needed from the user and how the program is terminated.

Once the user viewed the help screen, striking any key will follow with
the display of the menu again.

 

Suggested help function prototype is:

 

 void help(void);

 

If the user selects s, or S function SubIntegers() is called and the user is prompted for two valid numbers of type int. Use function getInteger() to read an integer data from the user and return that value via the return statement to the function SubIntegers(). Function getInteger() is called twice to read the two operands needed for the subtraction operation. The SubIntegers() function will then call function displayIntegers() to display the two operands and the difference in the format shown below. For example, if the two double numbers are 18 and 40, then the result is displayed as shown below.

 

The difference is    18 - 40 = -22

 

There must be two digits after the decimal point.

 

Once the user viewed the result, striking any key will clear the screen, followed by display of the menu again. Function displayIntegers() will return the control to SubIntegers() and SubIntegers() will return the control back to the main() function where the instruction for the menu display was initiated.

function prototypes for this option are:

 void SubIntegers(void);

 

 int getInteger(void);

 

 void displayIntegers(int n1, int n2, int d);

 

If the user selects m, or M, function MulFloats() is called and the user is prompted for two valid numbers of type float. Use function getIFloat() to read a float data from the user and returns that value via the return statement to the function MulFloats(). Function getFloat() is called twice to read the two operands needed for the multiplication operation. The MulFloats() function will then call function displayFloats() to display the two operands and the product in the format shown below. For example, if the two float numbers are 6.34 and -36.45, then the result is displayed as shown below.

 

The product of    6.340 * -36.450 = -231.093

 

Once the user viewed the result, striking any key will clear the screen, followed by display of the menu again. Function displayFloats() will return the control to MulFloats() and MulFloats() will return the control back to the main() function where the instruction for the menu display was initiated.

 

Suggested function prototypes for this option are:

 void MulFloats(void);

 

 int getFloat(void);

 

 void displayIntegers(float& n1, float& n2, float& s);

 

 

Once the user viewed the result, striking any key will clear the screen, followed by display of the menu again.

 

If the user selects q or Q, the program clears the screen, displays the following message and the program will then terminate.

 

The program terminated per the user request…

 

Any other menu selection will be flagged as an error and the user is warned to make a valid selection from the menu, and the menu is displayed again. The wrong input should not terminate the program.

 

Once the program begins execution, it will not terminate until the user inputs q or Q.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution :

start read If N心刈蟲N ) Read a.h Switch n

  

     C. Case Print Case 2 Prirst Case 1 8 STOP

Figure : Flowchart   

CODE :

#include<stdio.h>

#include<conio.h>

Void main()

{

Int a,b,c,n;

Clrscr();

Printf(“ \n –menu-- “);

Printf(“\n 1 addition”);

Printf(“\n 2 subtraction”);

Printf(“\n 3 multiplication”);

Printf(“\n4 division”);

Printf(“\n enter your choice : “);

Scanf(“%d”,&n); If(n<=4 & n>0)

{

Printf(“\n enter two numbers”);

Scanf(“%d %d”,&a,&b);

}

switch(n)

{

case 1: c=a+b;

printf(“\n Addition : %d”,c);

break;

case 2: c=a-b;

printf(“\n subtraction: %d”,c);

break;

case 3: c=a*b;

printf(“\n multiplication: %d”,c);

break;

case 4: c=a/b;

printf(“\n division:%d”,c);

break;

default:

printf(“\n invalid operation code”);

}

getch();

}

Add a comment
Know the answer?
Add Answer to:
Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that displays a menu on the screen. The menu will give the user...

    Write a program that displays a menu on the screen. The menu will give the user four options - enter two integers, enter two decimal numbers (#.#), enter one integer and one decimal number, or quit. The inputs should be labelled a, b, c, or d, and you should enter in the letter to choose the appropriate option. Once the user selects the option, two numbers will be read in from the user. The numbers will be added together and...

  • Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle...

    Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle 2. Area of square 3. Area of rectangle The program should use the following functions properly: void displayMenu() //a function that will display the menu options to the user int getChoice() //a function that will input the user choice and returns it float calculate(int choice) //a function that reads the required inputs based on the user choice, and returns the area of the shape...

  • ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels...

    ‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...

  • Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses...

    Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment.  You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...

  • Write a contacts database program that presents the user with a menu that allows the user...

    Write a contacts database program that presents the user with a menu that allows the user to select between the following options: (In Java) Save a contact. Search for a contact. Print all contacts out to the screen. Quit If the user selects the first option, the user is prompted to enter a person's name and phone number which will get saved at the end of a file named contacts.txt. If the user selects the second option, the program prompts...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your...

    Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your pseudocode and C-program, use only what you have learned in this class so far. (Menu) Design a menu for question 2 and 3. So far, you use one program to solve all lab questions. But some of you may feel awkward when you want to demo/test only one lab question. To overcome that, your program should show a menu so that the users of...

  • Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit...

    Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit 1. For Erase-ArrayContent option, write complete code for the C++ function Erase described below. The prototype for Erase function is as follow: void Erase( int a[ ], int * N, int * Search-Element) The function Erase should remove all occurrences of Search-Element from the array al). Note that array a[ ] is loaded with integer numbers entered by the user through the keyboard. N...

  • CE – Return and Overload in C++ You are going to create a rudimentary calculator. The...

    CE – Return and Overload in C++ You are going to create a rudimentary calculator. The program should call a function to display a menu of three options: 1 – Integer Math 2 – Double Math 3 – Exit Program The program must test that the user enters in a valid menu option. If they do not, the program must display an error message and allow the user to reenter the selection. Once valid, the function must return the option...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT