mrloco
02-27-2005, 01:52 PM
I have run into some problems while trying to write a Pounds to kilos conversion program in c++. no matter what number i press, the program always goes to the kilos to pounds part...
here's the code.
#include <iostream.h>
void PoundsToKilos() {
cout << "Enter the value in Pounds\n";
float x;
cin >> x;
cout << "The value in kilos is=\n "<< x/2.2;
}
void KilosToPounds() {
cout <<"enter the value in Kilos\n";
float x;
cin>>x;
cout <<"the value in Pounds is= "<<x*2.2;
}
int main() {
int choice;
cout <<"Weight conversion Program\n";
cout <<"=========================\n";
cout <<"please choose\n";
cout <<"1.) Kilos to pounds\n";
cout <<"2.) Pounds to Kilos\n";
cin>>choice;
if (choice=1)
KilosToPounds ();
else if (choice=2)
PoundsToKilos ();
cin.get();
}
here's the code.
#include <iostream.h>
void PoundsToKilos() {
cout << "Enter the value in Pounds\n";
float x;
cin >> x;
cout << "The value in kilos is=\n "<< x/2.2;
}
void KilosToPounds() {
cout <<"enter the value in Kilos\n";
float x;
cin>>x;
cout <<"the value in Pounds is= "<<x*2.2;
}
int main() {
int choice;
cout <<"Weight conversion Program\n";
cout <<"=========================\n";
cout <<"please choose\n";
cout <<"1.) Kilos to pounds\n";
cout <<"2.) Pounds to Kilos\n";
cin>>choice;
if (choice=1)
KilosToPounds ();
else if (choice=2)
PoundsToKilos ();
cin.get();
}
