#include <iostream> #include <cstdlib> #include <iomanip> using namespace std; int main() { int totalReviews; int positiveReviews; int percentagePositive; cout << "Please Enter your total reviews" << endl; cin >> totalReviews; cout << "Please Enter your positive reviews" << endl; cin >> positiveReviews; percentagePositive == positiveReviews / totalReviews; cout << percentagePositive << endl; return 0; }

## 22 Replies - 1531 Views - Last Post: 03 February 2018 - 07:27 PM

### #1

# dividing by any numbers = 4354302

Posted 03 February 2018 - 04:15 PM

Hi, i am trying to make a basic dividing code, but no matter what numbers i use the output is 4354302, can anyone help

##
**Replies To:** dividing by any numbers = 4354302

### #2

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:17 PM

Remember == and = are different.

== is used to compare two objects and returns a boolean.

= is for assignment.

You should also think about the results.. integers are whole numbers - so no decimal points. Any remainders may be missing.

== is used to compare two objects and returns a boolean.

= is for assignment.

You should also think about the results.. integers are whole numbers - so no decimal points. Any remainders may be missing.

### #3

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:18 PM

OK i changed it and now it just outputs 0, any ideas?

### #4

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:22 PM

What numbers are you using?

Did you look into something that may show a remainder? Again, integers are whole numbers.

Did you look into something that may show a remainder? Again, integers are whole numbers.

### #5

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:24 PM

just for now i used 100 and 80, just to test as it is very easy, but 0, and if i change positiveReviews to float it makes no difference, still 0

### #6

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:29 PM

Let's see the current code.

### #7

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:30 PM

here you go

#include <iostream> #include <cstdlib> #include <iomanip> using namespace std; int main() { int totalReviews; int positiveReviews; float percentagePositive; cout << "Please Enter your total reviews" << endl; cin >> totalReviews; cout << "Please Enter your positive reviews" << endl; cin >> positiveReviews; percentagePositive = positiveReviews / totalReviews; cout << "Your percentage of positive results is " << percentagePositive << endl; return 0; }

### #8

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:33 PM

Think about casting your division problem to a float while assigning it to the float.

### #9

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:41 PM

Ok i fixed it by doing that, here is the current code.

Now I would like to be able to tell the user how many more positive reviews they would need to have a 90% positive review percentage, but it would need to be of the new percentage, not of the old. for example if a user had 80 positive reviews out of 100 total reviews, it would tell him that he needs a minimum of 100 more positive reviews to get a 90% positive review rate. I have no idea how to do that, and would be great if i could get some pointers

Now I would like to be able to tell the user how many more positive reviews they would need to have a 90% positive review percentage, but it would need to be of the new percentage, not of the old. for example if a user had 80 positive reviews out of 100 total reviews, it would tell him that he needs a minimum of 100 more positive reviews to get a 90% positive review rate. I have no idea how to do that, and would be great if i could get some pointers

#include <iostream> #include <cstdlib> #include <iomanip> using namespace std; int main() { int totalReviews; int positiveReviews; float percentagePositive; cout << "Please Enter your total reviews" << endl; cin >> totalReviews; cout << "Please Enter your positive reviews" << endl; cin >> positiveReviews; percentagePositive = (float)positiveReviews / (float)totalReviews; cout << "Your percentage of positive results is " << percentagePositive*100 << endl; return 0; }

### #10

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:47 PM

It's an algebra equation.

Now:

percent = positive / total

If you want positive, but have a percent and total how would you go about solving for positive?

Now:

percent = positive / total

If you want positive, but have a percent and total how would you go about solving for positive?

### #11

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 04:54 PM

I understand that but say if someone has 80/100, and they get 10 more positive, it wont be 90/100, it will be 90/110, so 81.8%, so I need to write a line of code that will tell a user how many more positive they need for 90%, which in this case would be 100, as 180/200 is 90%

### #12

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:15 PM

Your problem is not coding currently.

If you can do the maths on the back of an envelope, then coding the resultant equation is trivial.

So sit down with pen and paper and solve the problem there...

If you can do the maths on the back of an envelope, then coding the resultant equation is trivial.

So sit down with pen and paper and solve the problem there...

### #13

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:20 PM

oh forgot to update, I've got it finished now

### #14

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:22 PM

Well done!

You seem to be having a busy day today...

You seem to be having a busy day today...

### #15

## Re: dividing by any numbers = 4354302

Posted 03 February 2018 - 05:25 PM

yeah, starting 11th grade CIT (coding / computer study), and want to get as far into it as I can during the long weekend that i have

thanks for help all

thanks for help all