Question: C++ Take in a value in inches and a command in which to convert to. The commands are as follows: m millimeters C centimeters M

C++ Take in a value in inches and a command in which to convert to. The commands are as follows:

m millimeters

C centimeters

M meters

Example 1 m would convert 1 inch to millimeters.

1 inch = 25.4 millimeters

1 inch = 2.54 centimeters

1 inch = 0.0254 meters

Use a switch statement to determine what to convert to.

(my code)

#include using namespace std; int main() { int val; int choice; cout << "enter amount of inches" << endl; cin >> val; cout << "1. m millimeters" << endl; cout << "2. C centimeters" << endl; cout << "3. M meters" << endl; switch(choice) { case 1: cout << "that is " << val * 25.4 << "millimeters" << endl; break; case 2: cout << "that is " << val * 2.54 << "centimeters" << endl; break; case 3: cout << "that is " << val * 0.0254 << "meters" << endl; break; default: cout << "invalid entry" << endl; break; } return 0; }

(please fix it and tell me where i messed up.and there is some else who answered this but they use header.and my clas is only use "#include ".)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!