Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My question is why is my program running blank when I go to run it. Create a menu - driven application that supports the fol

My question is why is my program running blank when I go to run it.

Create a menu-driven application that supports the followingmenu options A. Miles to Kilometers, B. Kilometers to Miles, Q. Quit. Theprogram should continue to process conversions until Quit is selected. The overall designof your program is up to you. Your program should implement and use the following functions
double milesToKilometers(double miles); takes miles and returns kilometersdouble kilometersToMiles(double kilometers); takes kilometers and returns miles
char getMenuChoice();
getMenuChoice should display the required menu and prompt the user tomake a choice. The function should return choice as type char. Validationis optional.

Your main function should contain the menu switch (i.e. switch should not be in yourgetMenuChoice function). Also, your milesToKilometers, and kilometersToMilesfunctions should NOT contain any cin or cout statements. These functions are strictlycalculation functions (i.e. a single value is passed to the function, and a single value isreturned).

#include using namespace std; char getMenuChoice(); double convertMilestoKilometers(double miles); // function miles to kilometers double convertKilometerstoMiles(double kilo); // function kilo to miles int main() { char getMenuChoice(); int choice; double number; while (true) { cin >> choice; switch (choice) { case 'A': cout << "Miles to be converted: "; cin >> number; cout << number << " Miles = " << convertMilestoKilometers(number) << " kilometers " << endl; break; case 'B':cout << "kilometers to be converted: "; cin >> number; cout << number << " Kilometers = " << convertKilometerstoMiles(number) << " miles " << endl; break; case 'Q': return 0; } } } char getMenuChoice() { int choice; cout << " Menu Driven Conversion Calculator " << endl; // name of the program cout << "---------------------------" << endl; // menu design cout << "A. Convert miles to kilometers" << endl; cout << "B. Convert kilometers to miles" << endl; cout << "Q. Quit " << endl; cout << "------------------------" << endl; cout << "Make a choice" << endl; cin >> choice; return choice; }

double convertMilestoKilometers(double miles) { return miles*1.6093; } double convertKilometerstoMiles(double kilo) { return kilo*.6214; }

Create a menu-driven application that supports the followingmenu options A. Miles to Kilometers, B. Kilometers to Miles, Q. Quit. Theprogram should continue to process conversions until Quit is selected. The overall designof your program is up to you. Your program should implement and use the following functions
double milesToKilometers(double miles); takes miles and returns kilometersdouble kilometersToMiles(double kilometers); takes kilometers and returns miles
char getMenuChoice();
getMenuChoice should display the required menu and prompt the user tomake a choice. The function should return choice as type char. Validationis optional.

Your main function should contain the menu switch (i.e. switch should not be in yourgetMenuChoice function). Also, your milesToKilometers, and kilometersToMilesfunctions should NOT contain any cin or cout statements. These functions are strictlycalculation functions (i.e. a single value is passed to the function, and a single value isreturned).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

Define Decision making

Answered: 1 week ago

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago