In the hovercraft problem for c++, my code won't work and I don't know why | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 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";} }

16th Mar 2023, 4:58 PM
Lucien Keating
Lucien Keating - avatar
2 Antworten
+ 2
Nevermind, I figured it out, it's a ==, not a =
16th Mar 2023, 5:04 PM
Lucien Keating
Lucien Keating - avatar