【发布时间】:2015-12-02 04:06:30
【问题描述】:
我是编程的初学者,我目前正在尝试制作一个从公斤到磅的转换程序,反之亦然。我不擅长阅读错误代码,所以有人可以告诉我,我做错了什么。
#include <iostream>
using namespace std;
int main()
{
char response;
double Kilo_const = 0.45, Pound_const = 2.20, Kilo_output, Pound_output;
double Kilo_input, Pound_input;
cout << "Choose the input unit \nk = kilo and p = pound" << endl;
cin >> response;
if (response == 'k'){
cin >> Kilo_input;
cout << Pound_output = Kilo_input * Pound_const << endl;
}
else (response == 'p'){
cin >> Pound_input;
cout << Kilo_output = Pound_input * Kilo_const << endl;
}
return 0;
}
【问题讨论】:
-
请贴出错误信息