Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

need halp

Name: Anonymous 2009-03-19 20:52

alright so for my begining c++ class i have to create a program that taxes certain incomes a certain amount depending on how much they make

anyways i just have a problem for the highest level which i need to do the following for over 5000.01 income the tax rate is 1% for the first $3000 + 5% for the next $1000 + 7% of the next 1000 + 1% for every $1000 over $5000

so basically i have this

if (income >= 5000.01)
{
taxMod = income - 5000.00;
overTax = ??? need help here!
taxes = (3000.00 * .01) + (1000.00 * .05) + (1000.00 * .07) + overTax;
}

so i need to make overTax get rid of any excess above the last thousand and then tax 1% of every thousand, the thing is I have no idea how to do that

Name: Anonymous 2009-03-19 21:10

Three things:

1. Don't ever store money as a floating point number. Use an integer type to store cents if you need cent-level precision, or whole dollars in this case (if you explained your assignment correctly, which I don't think you did).

2. % is the modulo operator. / is the whole division operator when used on integers. Understand both and use them.

3. Keep this fucking shit off /prog/. We aren't here to help you with your homework. Go ask Stack Overflow or something.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List