+ 1

# C++ code help, I think Iâ€™m solving this incorrectly.

In c++ practice lesson 18.2 am I meant to solve the problem by using a double instead of the int it gave me? At that point I have not learned them yet but am told thatâ€™s the only way? Any suggestions on other ways to solve Iâ€™m kinda stumped and feel like Iâ€™m missing something from that lesson and a little bit of insight would go a long way. -thanks in advance!!

3 Answers

+ 1

You have to divide by 100.0, cuz 15/100 is always 0.
If you divide integers, result will always get rounded to lower value (100/15=0.15â‰ˆ0)
Or just multiply by 0.15

+ 2

Show us what youâ€™ve done so far.

+ 1

#include <iostream>
using namespace std;
int main()
{
int purchaseAmount = 0;
double totalPrice;
//your code goes here
do{cin>>totalPrice;
totalPrice=totalPrice*15/100;
cout<

Hot today

What is indentations... ?

6 Votes

Q. Anna is 18 years old

-2 Votes

int num = 2;
int x = 3;
if(num >= 2) {
if(x > 4) { num = 3; }
else { num = 4; }
}
else {x = 1; }

1 Votes

About Java McQ

0 Votes

Need solution

0 Votes

YouTube Link Finder

0 Votes