okay so im new to programming and have an assignment im not sure how to do the question is.

The original U.S. income tax of 1913 was quite simple. The tax was

1 percent on the first \$50 000
2 percent on the amount over \$50 000 up to \$ 75 000
3 percent on the amount over \$75 000 up to \$100 000
4 percent on the amount over \$100 000 up to \$ 250 000
5 percent on the amount over \$250 000 up to \$ 500 000
6 percent on the amount over \$500 000

1) it looks like you want us to do it for you
2) we have no idea what you're having trouble with

When posting, details are more important than posting the assignment.

yeah i understand lol uhm i think i have kind of started to figure it out if it doenst work i will post what i have done so far wondering why it does not work thanks.

well this is what i have so far and it doesnt work and im not quite sure why

``````#include <iostream>

int main ()
{
int itrate;
float salary,itax,nsalary=0;
cout << "Enter the salary : ";
cin>>salary;
if(salary<50000)
{
itax=salary*1/100;
itrate=1;
}``````

1 / 1000 = 0. Integer math has no decimals.

You need floating point math: 1.0/1000.0 has decimals.

Okay so I finished what i though was right but yeah, it doens't work here is what i have, just wondering if you could possibly tell me where it is not working cause like I mentioned I have just started a month ago and am not able to pick up easily on mistakes. this is what i have

``````#include <iostream.h>
#include <conio.h>

void main ()
{
clrscr();
int itrate;
float itax;
cout << "Enter the salary :";
cin >> salary;
if(salary>500000)
{
itax=salary*6.0/100.0;
itrate=6.0;
}
else if (salary>250000
{
itax=salary*5.0/100.0;
itrate=5.0;
}
else if (salary>100000
{
itax=salary*4.0/100.0;
itrate=4.0;
}
else if (salary>75000
{
itax=salary*3.0/100;
itrate=3.0;
}
else if (salary>50000
{
itax=salary*2.0/100;
itrate=2.0;
}
else (salary>25000
{
itax=salary*1.0/100;
itrate=1.0;
}
cout << "Your income tax @ " << itrate << "% = \$" << itax << endl;
getch();
}``````

Okay so I finished what i though was right but yeah, it doens't work here is what i have, just wondering if you could possibly tell me where it is not working cause like I mentioned I have just started a month ago and am not able to pick up easily on mistakes. this is what i have

This is frustrating -- sorry.

Why is it new people expect us to
1) read the code and try to understand what it's trying to do?
2) try to figure out what might be wrong with no clues?
3) come up with a solution?

You'd thing that the person with the problem who just ran the code and knows what went wrong would tell us what happened , rather than leaving it to us to guess.

Sorry for the rant, but this is the 5th post I've seen with "it's broke, tell me why" attitude in the last half hour.

yeah i understand what you mean, if i had any clue what i was doing I'd tell you but im really not sure what it means im pretty sure my else if statements are true so i think its something at the beginning/ending. when i go to compile the code it says path cannot be specified and im not sure what that means.

As for your code: `#include <iostream.h>` -- who's still teaching coding practices from the 1980's? The industry moved forward, you are being taught very old concepts which is crippling you. `#include <conio.h>` -- same with this. It's only good on a couple compilers and is non-standard. Will not work on most compilers. More stuff to unlearn when you upgrade to a current compiler. Again, a disservice to your education. `void main ()` -- this is just wrong, and has been since the language was designed. See this `clrscr();` -- conio.h problem. And you've just pinpointed the one and only compiler -- Turbo C/C++. Probably version 3 (1991) would be my guess. Note that only Turbo C++ has this command. What happens when you move forward to a compiler from 1996 or newer.
Also, this is an executable statement and cannot be before the definitions following it. `itax=salary*6.0/100.0;` -- why not 0.06 instead of 6/100? It's simpler.

And they need to teach you how to format your code. If your code was any more complex is would be too hard to follow. Learn formatting now before you move on. Trust me, it's extremely important.

yeah i understand what you mean, if i had any clue what i was doing I'd tell you but im really not sure what it means

What what means? This is what I'm complaining about. You seem to have been given some kind of information, but you aren't sharing it. If the code is running, what did you type in, what did the code display, and what were you expecting to see?
If the code isn't running, why? What happened?

im pretty sure my else if statements are true so i think its something at the beginning/ending. when i go to compile the code it says path cannot be specified and im not sure what that means.

Neither are we if you don't tell us exactly what the compiler/program is telling you. Don't type it in, and don't paraphrase. Copy/paste like you did your code.

okay well i have been modifying my code and this is what i currently have. I am using the program microsoft visual studio 2008 if thats clears anything up?

``````#include <iostream>
using namespace std;

int main ()
{
float itax;
cout << "Enter the salary :";
cin >> salary;
if(salary>500000)
{
itax=salary*0.05;
itrate=6.0;
}
else if (salary>250000)
{
itax=salary*0.05;
itrate=5.0;
}
else if (salary>100000)
{
itax=salary*0.06;
itrate=4.0;
}
else if (salary>75000)
{
itax=salary*0.03;
itrate=3.0;
}
else if (salary>50000)
{
itax=salary*0.02;
itrate=2.0;
}
else
{
itax=salary*0.01;
itrate=1.0;
}
cout << "Your income tax @" << itrate << "% = \$" << itax << endl;
getch ();
}``````

and the feed back that i recieve is:

1>d:\my documents\programming\assignments\assignment 2\p.3.17\p.3.17\p.3.17.cpp(22) : error C2065: 'salary' : undeclared identifier

1>d:\my documents\programming\assignments\assignment 2\p.3.17\p.3.17\p.3.17.cpp(23) : error C2065: 'itrate' : undeclared identifier

and im not sure how to declare it

okay so after much googling and reading and tweaking of my code and realising my program imputs at the bottom i have finally cracked my code and it works. this is what i have

``````int main ()
{
double salary;
double itax;
double itrate;

cout << "Enter the salary :";
cin >> salary;
if(salary>=500000)
{
itax=salary*0.06;
itrate=6.0;
}
else if (salary>250000)
{
itax=salary*0.05;
itrate=5.0;
}
else if (salary>100000)
{
itax=salary*0.04;
itrate=4.0;
}
else if (salary>75000)
{
itax=salary*0.03;
itrate=3.0;
}
else if (salary>50000)
{
itax=salary*0.02;
itrate=2.0;
}
else
{
itax=salary*0.01;
itrate=1.0;
}
cout << "Your income tax @" << itrate << "% = \$" << itax << endl;
}``````

okay well i have been modifying my code and this is what i currently have. I am using the program microsoft visual studio 2008 if thats clears anything up?

===
and the feed back that i recieve is:

1>d:\my documents\programming\assignments\assignment 2\p.3.17\p.3.17\p.3.17.cpp(22) : error C2065: 'salary' : undeclared identifier

1>d:\my documents\programming\assignments\assignment 2\p.3.17\p.3.17\p.3.17.cpp(23) : error C2065: 'itrate' : undeclared identifier

and im not sure how to declare it

Yes!!! Details.

You need to define salary and itrate before you can use them.

You defined itax, `float itax;` these others are no different. Just decide if they are floats, ints, or whatever.

yeah thanks i ended up getting it
how do i determine if my variable is int double or float??

yeah thanks i ended up getting it
how do i determine if my variable is int double or float??

Ambiguous....

Q1: How can I tell if the variable is a double of float? Look at the definition. If it says `float var;` it's a float.

Q2: How can I tell if the variable should be a double of float? Does the variable need to have a decimal? If so, `float` .

Okay so i have a new problem for another question i am trying to find an algorithm to add every other number starting at the far right for a set of numbers this is what i have so far:

``````public static bool IsCardNumberValid(string cardNumber)
{
int i, checkSum = 0;

// Compute checksum of every other digit starting from right-most digit
for (i = cardNumber.Length - 1; i >= 0; i -= 2)
checkSum += (cardNumber[i] - '0');

// Now take digits not included in first checksum, multiple by two,
// and compute checksum of resulting digits
for (i = cardNumber.Length - 2; i >= 0; i -= 2)
{
int val = ((cardNumber[i] - '0') * 2);
while (val > 0)
{
checkSum += (val % 10);
val /= 10;
}
}

// Number is valid if sum of both checksums MOD 10 equals 0
return ((checkSum % 10) == 0);
}``````

and my feed back says:

1>chea.cpp
1>d my documents\visual studio 2008\projects\p4.2\p4.2\chea.cpp(12) : fatal error C1021: invalid preprocessor command 'inlcude'

1>Build log was saved at "file://d:\My Documents\Visual Studio 2008\Projects\P4.2\P4.2\Debug\BuildLog.htm"
1>P4.2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Well, look carefully at the error. What does it say is invalid?