0

Everyone loves a discount

#include <iostream> using namespace std; int main() { int purchaseAmount; int totalPrice; //your code goes here do{ cin >> totalPrice; purchaseAmount = purchaseAmount + 1; totalPrice = totalPrice * .15; cout << totalPrice << endl; }while(purchaseAmount<3); return 0; } Everything’s correct except last out put How do I make the first 2 outputs normal and the last a float?

4th Dec 2021, 4:57 PM
Cody Silvaggio
9 Respuestas
0
@ You're always Welcome😇
4th Dec 2021, 6:12 PM
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ.
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ. - avatar
+ 1
Cody Silvaggio I think it is 0.15, if I am not wrong. So for that I would say, change the data type to double !!!
4th Dec 2021, 6:03 PM
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ.
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ. - avatar
+ 1
Cody Silvaggio Actually, There is no restriction on you while attempting any code project, that you can't edit the existing code.😄😄 So you could even use a different approach😎 to run the code correctly. So you can try that!!👍👍
4th Dec 2021, 6:11 PM
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ.
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ. - avatar
0
Cody Silvaggio can you clarify ' .15' at the end of totalPrice =.......... !! Is it 0.15 or a dot is there by mistake😐
4th Dec 2021, 6:02 PM
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ.
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ. - avatar
0
Ty!!!
4th Dec 2021, 6:12 PM
Cody Silvaggio
0
Learner_Pratham so i tried double and still only gota the first two out puts correct
4th Dec 2021, 8:12 PM
Cody Silvaggio
0
Cody Silvaggio Okay!! So can you tell the question, what is it saying?? Or you can just tell me the reference of that question Like: Platform where this question is, the lesson, is it a code project or practise question, etc.
5th Dec 2021, 1:08 AM
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ.
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ. - avatar
0
Learner_Pratham nvm i figured it out, i was not floating the variable itself but was using float within the equation but then floated the variable and it worked
5th Dec 2021, 2:12 PM
Cody Silvaggio
0
Cody Silvaggio Ok great then👏. Good job👍👍✌.
5th Dec 2021, 6:53 PM
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ.
(☞ ಠ_ಠ)☞.ρrΑτΗαΜ. - avatar