Greetings, first time I've posted here. Forgive me if I touch on any taboos unique to this forum. My teacher isn't very good and my textbook is virtually useless or I wouldn't be seeking help on the internet.
I did read the homework sticky, though.
It's basically an exercise in loops and if/else statements.
We're calculating commisions and witholding on sales from a data file we have to access inside the program.
The data file has a setup basically like this, the first number being an employee ID and the second being their sales.
6829 45967.28
1111 25000.11
...
...
2222 22222.00
And the program is as follows, without some of the comments at the beginning that would be used by my teacher.
#include <stdio.h>
#include <math.h>
main ()
{
int id;
double com, wit, sales;
FILE *inp;
inp=fopen ("prog2.dat", "r");
while (fscanf (inp, "%d %d", &id, &sales) !=EOF)
{
if (sales <=30000)
{com= (.2*sales)}
else
{com =6000+(.2*sales)}
if (com <=3000)
{wit=.05*com}
else if (3000<com && com<=6000)
{wit=150+(.07*com)}
else if (6000<com && com<=10000)
{wit=360+(.09*com)}
if (10000<com)
{wit=720+(.12*com)}
printf("ID=%d Commission=$%8.2f Withholding_Tax=$%5.2f\2", id,com,wit);
}
}
My progam keeps spitting out that there's a parse error on my if/else lines. I don't have any idea what that might be.
If some of the program doesn't make sense that's because I don't fully understand the uses of everything and I simply imitated what I've seen before.
Thanks in advance, folks.