Sorry to bother everyone but, I've only been at C++ since Wednesday. I need to know how to multiply decimals. Been looking for a FAQ or something but maybe I did not look hard enough.
This is my code
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
It looks pretty bad right now I know. I've been emailing friends but they keep giving different answers. The last part of this is just the calculations. If I can get grosspay * federalIncomeTax to show the proper decimal instead of a huge
number or 0 I'll be fine. If anyone can tell me what is wrong I'll be grateful. Thanks.
What kind of integer is 0.15 ? Doesn't look like an integer to me.
I see that your code calculates incomeTax using the value grosspay before grosspay has been given a value. If you want better results, you will have to give grosspay the right value before you use it.
It isn't. Like I said I'm going off of what people have been telling me. At first a friend told me to make it a double so it could have decimal places. After that I changed it to something, and then something else again. This is the final mess we're looking at. What should it be?
Yeah, I know that lol. It WAS (key word being was) much neater. I'm aware that that I need to have things in that order. But when I got to the calculations, I always got 0 or another whole number. If I can figure out how to multiply the grosspay (which is a decimal) by the other values (which is are decimals)and not get zeroes I'd be okay.
Whenever you use a double where C++ expects an int this will happen:
1 2 3 4
int n = .5; //.5 gets cast to (turned into) an int, so n is now 0 (the integer part of .5)
double x = .4; //fine
cout << n * x << '\n'; //it prints 0 because n contains 0 and x contains .4, (0 * .4 == 0)
//instead make n a double
Dude... THANK YOU. Like I said, I've only been at it since Wednesday. I tried this on a much smaller program I made and it worked! If I turn those others into doubles it should be cool, right?