输入摄氏度/华氏度,然后进行转换
Input Celsius/Fahrenheit then convert
所以我正在编写一个c++代码,该代码应该询问用户是想使用摄氏度还是华氏度,然后询问他们度数,然后转换它。我的程序不会编译,抱怨编译器需要一个标识符,而我缺少一个;在识别字符之前。请详细地告诉我我的代码到底出了什么问题。请记住,我是新来的,非常感谢提供任何信息,但我不会理解更复杂的术语/代码。
#include <iostream>
using namespace std;
int main()
{
char 'C';
double degree;
int degree_type;
cout << "What's the Degree type?: ";
cin >> degree_type;
if (degree_type == 'C')
{
cout << "What's the Temperature?: ";
cin >> degree;
cout << degree << " degrees Celsius is = " << 9 / 5 * degree + 32 << " Degrees Fahrenheit" << endl;
}
else
{
cout << "What's the Temperature?: ";
cin >> degree;
cout << degree << " degrees Fahrenheit is = " << (degree - 32) * 5/9 << " Degrees Celsius" << endl;
}
return 0;
}
您必须删除char'C'并将"degree_type"的类型更改为char,类似这样。
//char 'C'; Comment this line or remove
double degree;
char degree_type; // change this
相关文章:
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 从/到 UTF-8/UTF-16 的转换需要(例如:utf8 -> 代码点,然后代码点到 utf16)或(例如:utf8 -> utf16)?
- 使用 GDI+ 旋转位图,然后转换为 HDC
- 将子字符串字符从字符串值转换为 int,然后将其分配给 int 变量
- 将函数应用于元组中的每个元素,将每个元素强制转换为类型包中的不同类型,然后作为参数包传递
- 检查字符串是否是数字,然后将该数字转换为 int?
- 将 char[] 数组转换为字节,然后将字节转换为 int,反之亦然
- 将多映射转换为空指针,然后转换回多映射
- 将 int 转换为字符串,然后连接另一个变量以创建完整扩展名,然后将其转换为 const_char*
- 如何将两个 jlong 数据类型转换为 jstring,然后将两个字符串连接在一起以便从 JNI 将字符串返回给 jav
- 将40个字节长的数据框从十六进制转换为二进制,然后转换为十进制
- strtoull() 的输出在转换为双精度然后又转换为 uint64_t 时会失去精度
- 将整数向量转换为字节数组向量,然后调用每个字节数组
- 将无符号字符转换为字符串,然后再次转换为无符号字符
- 获取字符数组地址,然后转换为指针字符
- 在C++中一次一行地从文本文件中读取int(好的字符,然后转换)时出现问题
- 将uchar转换为int,然后转换为字符串会导致崩溃
- 将浮点数四舍五入到小数点后一位,然后转换为字符串
- 将整数的数字拆分为向量,旋转它们,然后转换回整数
- 将向量<char>作为参数,然后转换为字符串