0
フィートとインチからメートルとセンチメートルに変換するコードを作成することになっています。しかし、自分のコードを実行すると、私は何を得るべきかを知ることができません。たとえば、1フィートと0センチメートルを入力します。私は0.3048メートルと0センチメートルを取得する必要がありますが、代わりに私は1メートルと0センチメートルを得ています。助けて!C++出力変換エラー
#include <iostream>
using namespace std;
void getLength(double& input1, double& input2);
void convert(double& variable1, double& variable2);
void showLengths(double output1, double output2);
int main()
{
double feet, inches;
char ans;
do
{
getLength(feet, inches);
convert(feet, inches);
showLengths(feet, inches);
cout << "Would you like to go again? (y/n)" << endl;
cin >> ans;
cout << endl;
} while (ans == 'y' || ans == 'Y');
}
void getLength(double& input1, double& input2)
{
cout << "What are the lengths in feet and inches? " << endl;
cin >> input1 >> input2;
cout << input1 << " feet and " << input2 << " inches is converted to ";
}
void convert (double& variable1, double& variable2)
{
double meters = 0.3048, centimeters = 2.54;
meters *= variable1;
centimeters *= variable2;
}
void showLengths (double output1, double output2)
{
cout << output1 << " meter(s) and " << output2 << " centimeter(s)" << endl;
}
助けていただければ幸いです。ありがとう!
http://ericlippert.com/2014/03/05/how-to-debug-small-programs/ – Biffen
'meters * = variable1'は' meters =メートル* variable1'、すなわちあなたは 'meに乗算の結果を割り当てますters'。 –