Who doesn't like discounts? Exercise C++ [SPOILER]
Hey all, Been blocked on this exercise for a while now. Here's the subject: A supermarket has launched a campaign offering a 15% discount on 3 items. Write a program that takes the total price for every purchase as input and outputs the relevant discount. ## code ## #include <iostream> using namespace std; int main() { int purchaseAmount = 0; int totalPrice; //your code goes here do { cin >> totalPrice; float purchaseAmount = totalPrice * 0.15; cout << purchaseAmount << endl; } while (totalPrice); // Tried (totalPrice < 3) return 0; } The result is an infinite loop with the last input. I know there's a detail I've miss but still can't figure out what T_T Any tips? :/