+ 2
In the hovercraft problem for c++, my code won't work and I don't know why
In test case 2 the output should only be Profit, but it says its both profit and breaks even, which means that both my if > than and my if = to are both true, but they shouldn't be. Can someone tell me what I did wrong? #include <iostream> using namespace std; int main () { auto build=20000000; int costsell=3000000; int insurance=1000000; int amountbought; cin >> amountbought; int total = (amountbought*costsell); if (total>21000000) {cout << "Profit";} if (total=21000000) {cout << "Broke Even";} if (total<21000000) {cout << "Loss";} }
2 Réponses
+ 2
Nevermind, I figured it out, it's a ==, not a =