Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am new to C++ learning and I want to create an unit conversion program, not Win32, just console based at the moment in Visual

I am new to C++ learning and I want to create an unit conversion program, not Win32, just console based at the moment in Visual studio.

So far I wrote some code just for the Temperature unit conversion, and this is menu driven type of conversion.

I would like help on writing the main menu with the following,

(Distance) (Area) (Volume) (Mass) (Temperature) (Go back)

(End program)

It does not have to be in this order.

I need help to get the temperature code to be inside a submenu, as well as the above listed sub menus.

So if user choose (Area) in example, he should get to the (Area) menu where user can select what to convert and simply type what user needs to be converted.

Then be able to get back to the main menu and select something else to convert or exit the program.

For (Area) sub menu conversions should be: Angstrom, microns, meter, inches, feet

For (Distance) sub menu conversions should be: squaremeters, squarefeet, squareinches, squareyards

For (Volume) sub menu conversions should be: cubicmeter, cubicinches, cubicfeet, cubicyards, deciliters, liters

For (Mass) sub menu conversions should be: gram, ounces, pounds

For (Temperature) submenu which I already have and will improve it should look as it is posted below.

Below is the code for Temperature sub menu. Not 100% english but thats not the point here.

#include using namespace std;

int main(int argc, char** argv) { //valg variabel int nValg; double GraderF, GraderC, GraderK;

do {

//vis meny for Temp cout << "|| (Temperature) || " << endl << endl; cout << "1. Konvert Fahrenheit to Celcius "; cout << "2. Konvert Fahrenheit to Kelvin "; cout << "3. Konvert Celcius to Fahrenheit "; cout << "4. Konvert Celcius to Kelvin "; cout << "5. Konvert Kelvin to Fahrenheit "; cout << "6. Konvert Kelvin to Celcius "; cout << "7. End "; cout << "Valg:"; cin >> nValg;

//Multi valgstruktur switch statement switch (nValg) { case 1: cout << "Enter temp in Fahrenheit: "; cin >> GraderF; cout << (5.0 / 9.0)*(GraderF - 32) << " Grader Celcius." << endl; break; case 2: cout << "Enter temp in Fahrenheit: "; cin >> GraderF; cout << (5.0 / 9.0) * (GraderF - 32) + 273.15 << "Kelvin"; break; case 3: cout << "Enter temp in Celcius : "; cin >> GraderC; cout << (GraderC * 9.0) / 5.0 +32 << "Fahrenheit" << endl; break; case 4: cout << "Enter temp in Celcius: "; cin >> GraderC; cout << GraderC + 273.15 << "Kelvin: "; break; case 5: cout << "Enter temp in Kelvin: "; cin >> GraderK; cout << (9.0 / 5.0)*(GraderK - 273.15) << "Fahrenheit"; break; case 6: cout << "Enter temp in Kelvin"; cin >> GraderK; cout << GraderK - 273.15 << "Grader Celcius: "; case 7: cout << "Thank you for using Converter DEMO."; break; default: cout << "Wrong choice." << endl;

}

cout << endl << endl << endl;

} while (nValg != 7);

system("pause"); return 0; }

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_2

Step: 3

blur-text-image_3

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions