Question

Need help with following C++ program: 3) Write a program in C++ with a menu. When...

Need help with following C++ program: 3) Write a program in C++ with a menu. When the program executes it gives the user a list of choice to choose from. The user can input 1,2 or 3 only. For all other input, the message “Invalid Options” will be displayed. ****MENU**** 1) Convert length from feet to inches. 2) Convert length from meter to centimeters. 3) To quit the program

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

Here is your code...

#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
   int a;
cout<<"Please enter a valid choice :"<<endl;
   cout<<"1) Convert length from feet to inches."<<endl;
   cout<<"2) Convert length from meter to centimeters."<<endl;
   cout<<"3) To quit the program."<<endl;
   cin>>a;
   switch(a)
{
   case 1:
       float inches,feet;
       std::cout << "Please enter length in feet:";
       std::cin >> feet;
       inches = feet*12;
       std::cout << feet << " feet is equivalent to " <<inches << " inches";
           break;
   case 2:
       int meter,centimeters;
       std::cout << "Please enter length in meters:";
       std::cin >> meter;
       centimeters = meter*100;
       std::cout << meter <<" meters is equivalent to "<< centimeters << " centimeters";
           break;
   case 3:
       cout<<"Exiting";
       exit(10);
   default:
       cout<<"Invalid Option";
       break;
   }  
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Need help with following C++ program: 3) Write a program in C++ with a menu. When...
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 has a menu with a  layout below, that asks the user if they...

    Write a Program that has a menu with a  layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...

  • Java COSC 237 Problem: You are to develop a program that allows a user to convert...

    Java COSC 237 Problem: You are to develop a program that allows a user to convert lengths in the metric system (i.e., meters/centimeters) to the Imperial system (i.e., feet/inches) AND convert lengths in the Imperial system to the metric system. Specifications • Input may be given with or without decimal places. • Error checking for invalid input is not required. • The results are to be displayed with two decimal places of precision. (For example, 2 meters, 25 centimeters (225...

  • Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects....

    Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- rectangle 2 -- circle 3 -- triangle 4 -- quit If the user selects choice 1, the program should find the area of a rectangle. rectangle area = length * width If the user selects choice 2, the program should find the area of a circle. circle area = PI * radius * radius...

  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • I have this c++ program that i have to create but i am stuck on it....

    I have this c++ program that i have to create but i am stuck on it. Write a height conversion program that shall allow user to convert from feet and inches to meters (option 1) and vice versa (option 2). User shall be able to specify the type of conversion (a menu of two options). Display an error message if an invalid option is specified. Otherwise, the program would read in a length in feet and inches (two separate integer...

  • 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 For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • 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...

  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...

  • C++ Program with 2 functions 1. Hamming Functions Tester Write a function that displays a menu...

    C++ Program with 2 functions 1. Hamming Functions Tester Write a function that displays a menu to test the functions from 2 - 4. You must call the functions from 2 - 4 and cannot reimplement their functionality in this function. The menu is displayed as follows: 1) Enter a 4-bit message to encode into a 7-bit Hamming message. 2) Enter a 7-bit Hamming message to transmit through a noisy channel. 3) Enter a 7-bit Hamming message to receive and...

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