cout << "Welcome to the converter\n";
cout << "Please select function you would like to convert;\n";
cout << "1 - Degrees Fahrenheit to Celsius;\n";
cout << "2 - Inches to centimeters;\n";
cout << "3 - Pound to Stones.\n";
cout << "Please enter the digit here : ";
cin >> option;
switch(digit);
{
case '1' :
cout << "Please enter your Fahrenheit degrees here : ";
cin >> number;
answer = (number - 1) * .5556;
cout << "Fahrenheit converted to Celsius : " << answer;
break;
case '2' :
cout << "Please enter the amount of inches here : ";
cin >> number;
answer = number * 2.54;
cout << "Inches converted to centimeters : " << answer;
break;
case '3' :
cout << "Please enter the amount of pounds here : ";
cin >> number;
answer = number * 14;
cout << "Pounds converted to stones : " << answer;
break;
}
return 0;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#include<iostream>// use < > round iostreamusingnamespacestd;intmain(){intoption;intnumber;floatanswer;// define all variables number and answercout<<"Welcome to the converter\n";cout<<"Please select function you would like to convert;\n";cout<<"1 - Degrees Fahrenheit to Celsius;\n";cout<<"2 - Inches to centimeters;\n";cout<<"3 - Pound to Stones.\n";cout<<"Please enter the digit here : ";cin>>option;// use "option" not "digit"// do not end the switch with a ";"switch(option){case1:// remove single quotes from each 'number' we test for the value// not a stringcout<<"Please enter your Fahrenheit degrees here : ";cin>>number;answer=(number-32)*5/9;// corrected the formulacout<<"Fahrenheit converted to Celsius : "<<answer;break;case2:cout<<"Please enter the amount of inches here : ";cin>>number;// define answer as a float (see above)answer=number*2.54;cout<<"Inches converted to centimeters : "<<answer;break;case3:cout<<"Please enter the amount of pounds here : ";cin>>number;answer=number*14;cout<<"Pounds converted to stones : "<<answer;break;}return0;}
Last edit: Tarquin Delfino 2016-03-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
include "iostream"
include <windows.h>
using namespace std;
int main()
{
int option;
}
the following code works
Last edit: Tarquin Delfino 2016-03-21