Question

Using the Shapes program as an example, create a menu driven program that will do at least 5 metric conversions. You can do inches to centimeters, kilos to pounds, etc. You can use inches to centimeters, kilos to pounds, kilometers to miles, meters to feet and Celsius to Fahrenheit, etc.

Example Shapes program below
//A menu driven program to find area of shapes
#include <iostream>
using namespace std;
//function prototypes
void circle(void); //finds area of circle
void square(void); //finds area of square
void rectangle(void); //finds area of rectangle
void menu(void); //displays choices
void doChoice(char choice); //calls function selected
void main(void) //display menu and call function selected
{ char choice;
do
{ menu(); //display choices
cin>>choice;
doChoice(choice); //calls function selected
} while ((choice != 'Q') && (choice !='q'));
system("pause");
} //main
void doChoice(char choice) //calls function selected
{ switch (choice)
{ case 'C': case 'c': circle(); break;
case 'R': case 'r': rectangle(); break;
case 'S': case 's': square(); break;
} //choice
} //doChoice
void menu(void) //display the choices
{ cout<<"This will find the area of a shape\n\n";
cout<<"Enter the letter of your choice: \n";
cout<<"C: Circle\n";
cout<<"R: Rectangle\n";
cout<<"S: Square\n\n";
cout<<"Q: Quit\n";
cout<<"Please enter your choice:";
} //menu
void circle(void) //find area of circle from radius
{ double radius, area;
cout<<"Enter the radius of the circle:";
cin>>radius;
area = radius*radius*3.14158;
cout<<"The area is "<<area<<"\n\n";
} //circle
void rectangle(void) //find area of rectangle from length and width
{ double length, width, area;
cout<<"Enter the width of the rectangle:";
cin>>width;
cout<<"Enter the length of the rectangle:";
cin>>length;
area = width * length;
cout<<"The area is "<<area<<"\n\n";
} //square
void square(void) //find area of square from side
{ double side, area;
cout<<"Enter the side of the square:";
cin>>side;
area = side * side;
cout<<"The area is "<<area<<"\n\n";
} //square

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <iostream>

double centToInch(double cent);
double kiloToPound(double kilo);
double kilometerToMile(double kilometer);
double metersToFeet(double meters);
double celsiusToFahrenheit(double cels);

using namespace std;

int main()
{
    int choice;
    double measurement;

while(true)
{
cout << "Possible choices: " << endl;
cout << "1. Centimeters to inches" << endl;
cout << "2. Kilograms to Pounds" << endl;
cout << "3. Kilometers to Miles" << endl;
cout << "4. Meters to Feet" << endl;
cout << "5. Celsius to Fahrenheit" << endl;
cout << "6. Exit Program" << endl;
cout << "Choice: ";
cin >> choice;

   switch(choice)
   {
   case 1:
    cout << "Please enter the number of centimeters to convert: ";
    cin >> measurement;
    cout << measurement << " centimeters is equal to " << centToInch(measurement) << " inches" << endl;
    break;
   case 2:
    cout << "Please enter the number of Kilograms to convert: ";
    cin >> measurement;
    cout << measurement << " Kilograms is equal to " << centToInch(measurement) << " Pounds" << endl;
    break;...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Do-While Loop For a Ticket-Taker Problem
Homework Solution
$15.00
Programming
Computer Science
C++
Ticket-Taker
Prices
Do-While Loop
Discounts
Children
Constant Values
Integers
Sales
Messages
Input
Output
Repetition Structures
Homework Solution
$30.00
Computer
Science
C
Programming
Repetition
Structures
Table
Creator
Pseudocode
Lists in C++
Homework Solution
$25.00
Programming
Computer Science
C++
Nodes
Lists
Pointers
Algorithms
Header
Data
Inserting
Functions
Elements
Statements
Iterations
Programming Problems
Homework Solution
$50.00
Programming
C
Computer Science
Sorting
Integers
Arrays
Statements
Variables
Loops
Functions
Input
Output
Echo
Unix Commands
Memory
Strings
Line Arguments
Duplicates
Get help from a qualified tutor
Live Chats