我正在制作一个程序来评估某物的价值。我有一个变量保存要添加的总值,rcoverE
. 当我为第二个问题测试“y”时,它可以工作,但是当我输入“n”时,它无论如何都会增加 5。为什么会这样?
#include <iostream>
using namespace std;
int main(){
int year, yearE, rcoverE;
string rcover, func;
cout << "Enter the decade your thing was produced (eg. 20):";
cin >> year;
cout << "Does you typewriter have original thingy? (y,n):";
cin >> rcover;
rcoverE = 0;
if(rcover == "y" || "Y"){
rcoverE = rcoverE + 5;
}else{
rcoverE = rcoverE + 0;
}
cout << rcoverE;
yearE = 100 - year / 2;
}