嘿,所以我正在尝试一个提出这个问题的问题,请记住我只是在学习,但我不知道该怎么做,所以任何帮助都将不胜感激。
Q. 编写一个程序,根据用户输入将重量以 KG 为单位转换为磅和盎司,反之亦然。使用以下简单菜单: 重量转换选项:A) 公斤到磅和盎司。B) 磅和盎司到公斤。输入选项 A 或 B。
到目前为止,我有以下内容,但这就是我在卡住之前所能做的。
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float kg, ounces;
int pounds;
char option;
cout << "WEIGHT CONVERSION OPTIONS \n" << " " << "A) KG to pounds: \n" << " " << "B) Pounds to KG: \n " <<"Enter option A or B: \n";
cin.get(option);
if(option == A)
kg = option*2.2046;
cout << kg;
else if(option == B)
pounds = option/2.2046;
cout << pounds;
system("PAUSE");
}