Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using division 1

Status
Not open for further replies.

storygeek

Technical User
Jun 25, 2004
5
US
/* tax homework*/
#include <stdio.h>
main()
{
float income, net, totalco, avgp, totp, tax;
int count, ans, id;

printf ("Press 1 to run taxpayer anaylsis or any other key to stop program");
scanf ("%d", &ans);
while (ans == 1)
{
printf ("Taxpayer Id?");
scanf ("%d", &id);
printf ("Taxpayer's income?");
scanf ("%f", &income);
if ((income >= 0) && (income < 2390))
{
tax = 0;
net = income - tax;
}
else
if((income >= 2390) && (income < 3540))
{
tax = 11/100 (income - 2390);
net = income - tax;
}
else
if((income >= 3540) && (income < 4580))
{
tax = 126.50 + 12/100 (income - 3540);
net = income - tax;
}
else
if((income >= 4580) && (income < 6760))
{
tax = 251.30 + 14/100 (income - 4580);
net = income - tax;
}
else
if((income >= 6760) && (income < 8850))
{
tax = 556.50 + 15/100 (income - 6760);
net = - tax;
}
else
if((income >= 8850) && (income < 11240))
{
tax = 870.00 + 16/100 (income - 8850);
net = income - tax;
}
else
if((income >= 11240) && (income < 13430))
{
tax = 1252.40 + 18/100 (income - 11240);
net = income - tax;
}
else
if((income >= 13430) && (income < 15610))
{
tax = 1646.60 + 20/100 (income - 13430);
net = income - tax;
}
totalco = tax + totalco;
avgp = net/count;
totp = tax + totp;
printf ( "Id%d\t", id);
printf ( "# of employees%d\t", count);
printf ( "Income%f\t", income);
printf ( "Tax%f\t", tax);
printf ( "Net Income%f\t", net);
printf ("Press 1 to run taxpayer anaylsis or any other key to to stop program");
scanf ("%d", ans);
}

When ran thourgh the compiler I get an error that "100 can not be used as a function". In this program I'm trying to calculate the taxpayers' income, tax, net income and such. I tried 12% and .12. Would scientfic notation work?
 
> tax = 11/100 (income - 2390)
Perhaps you meant
[tt]tax = 11/100 * (income - 2390)[/tt]

Please use the [ignore]
Code:
[/ignore] tags around your code.

--
 
... the explanation for the wording of the error is that the compiler read 11/... and expected to see something it could treat as a number, by which to divide 11. Reading on, it found "100", but followed by "(". Something with the syntax "name(...)" is understood as a function called name, requiring parameters supplied in (), and quite possibly returning a number the compiler could make use of. Therefore it thought you were trying to call a function "100", which is unreasonable, because then it would have a hard job trying to work out whether a number was a number or a function.
 
Thanks salem and lionelhill. I didn't know that the c compiler recognize didn't () as a distributive parenthesis so I had to put a * to times it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top