0
What is wrong with my C++ programme? (17.2 practise)
#include <iostream> using namespace std; int main() { int purchaseAmount = 0; double totalPrice; double output= totalPrice*0.15; do { cin>>totalPrice; cout<<output<<endl; ++purchaseAmount; } while(purchaseAmount<3); //your code goes here return 0; }
3 Answers
+ 2
double output = totalPrice * 0.15; is not a definition of output that changes automatically every time, totalPrice gets a new value. It is an assignment, which will set output once, calculated from the current value of totalPrice.
That means, you need to calculate output anew each time you read a new value into totalPrice.
+ 1
Ani Jona š ah I see thanks :)
+ 1
You're welcome :)