Question regarding the response issue. I am having the user input 1 in order to calculate for meters/centimeters and 2 for inches and feet. It has to be an if/else statement, but whenever I run it, it continues onto the next calculation without selecting a choice. Any suggestions would be appreciated
Code:#include <iostream> using namespace std; void get_input ( double inches, double feet ); void give_output( double centimeters, double meters ); int main () { double inches, feet, meters, centimeters; char response = '1' || '2'; cout << "We are going to convert inches and feet into meters." << endl; cout << "Please input the measurement output you would like."; cout << "(1 for meter and centimeter output, 2 for inches and feet output)"; cin >> response; cout << endl; if ( response = 1 ) { void get_input ( double inches, double feet ); { cout << "Please input the feet measurement: "; cin >> feet; cout << endl; cout << "Please input the inches measurement: "; cin >> inches; cout << endl; } feet = inches * 12; meters = feet * 0.3048; centimeters = meters * 100; inches = feet / 12; void give_output( double centimeters, double meters ); { cout << " There are "; cout << meters; cout << " meters from the given measurements." << endl; cout << " There are "; cout << centimeters; cout << " centimeters from the given measurements." << endl; } } else ( response = 2 ); { void get_input ( double meters, double centimeters ); { cout << "Please input the meters measurement: "; cin >> meters; cout << endl; cout << "Please input the centimeters measurement: "; cin >> centimeters; cout << endl; } void give_output( double feet, double inches ); { cout << " There are "; cout << feet; cout << " feet from the given measurements." << endl; cout << " There are "; cout << inches; cout << " inches from the given measurements." << endl; } } }



LinkBack URL
About LinkBacks



