I'm writing a simple c++ measurement program that asks the user input to select from which unit they would like to measure the unit from and to the unit? but I don't know if the structure is correct (my C++ really sucks). Here is my code:
#include <iostream>
using namespace std;
int main()
{
int storeFROM, storeTO;
char mm, cm, m, kk;
cout << "Enter the initial unit (mm, cm, m, or km): ";
cin >> storeFROM;
cout << endl;
if ((storeFROM != 'mm') || storeFROM != 'cm' || storeFROM != 'm' || storeFROM != 'km') {
cout << "--> Sorry unit to convert FROM is invalid" << endl;
}
else if ((storeFROM == 'mm') || storeFROM == 'cm' || storeFROM == 'm' || storeFROM == 'km')
{
cout << "Enter the initial unit(mm, cm, m, or kk) :";
cin >> storeTO;
}
// Calculate the selected units
system("pause");
}
I hope someone can help me asking the user input to ask from which unit they want, this is exactly how it should show: