Thread: error message

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    18

    error message

    I keep getting a syntax error message right before the statetax in the while loop. But there isn't anything there
    Code:
    int main(void)
    
    {
            double salary = 0,sumtax = 0;
            double fedtax = 0.17;
            double statetax = 0.03;
    
       while (scanf("%lf",&salary) ==1)
            {
             fedtax = salary * fedtax
             statetax = salary * statetax
             sumtax = (salary - fedtax - statetax)
    
            printf("Value of Salary %lf", sumtax);
            }
    return 0;
    }
    Last edited by ke121885; 10-18-2009 at 03:46 PM. Reason: updated code

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You are right, there isn't anything there. Which is the problem, since the error message states "missing ; before statetax". Look before statetax, and see where the semicolon is missing.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    18

    pause

    In this Code:
    Code:
    int main(void)
    
    {
            double salary = 0,sumtax = 0;
            double fedtax = 0.17;
            double statetax = 0.03;
    
            printf("Enter your gross salary\n",salary);
       while (scanf("%lf",&salary) ==1);
            {
             fedtax = salary * fedtax;
             statetax = salary * statetax;
             salary = (salary - fedtax - statetax);
             sumtax = (fedtax + statetax);
            }
            printf("Value of Salary %lf\n", salary);
            printf("Value of Taxes %lf\n", sumtax);
    
    return 0;
    }
    I am getting a pause after the salary prompt and I can't actually get the answers until I hit ctrl D. Why does this keep happening?

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    So your answer for a missing a semicolon is to just add semicolons everywhere? Why don't you actually read your ........ing book?

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    18
    if I asking for help on a board that is used for help why are people getting mad? I haven't been doing programming forever and am just trying to learn what I am doing wrong. Sorry I am a bother but not everyone gets programming the first time around.

    ....and I do read my book but the one my class is using is sooo old that the teacher decided to not use it and just go on his own experience....so like I said I am TRYING to learn....

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    punctuationcanbeimportantithelpstodeterminethemean ingofwhatsgoingonandsoitssomethingyouneedtolearnho wtouse

    You should know why you do something, and not just type things at random. Tell us why you strewed semicolons throughout your program seemingly at random and we'll go from there.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    while (scanf("%lf",&salary) ==1); <-- must not have semicolon there!

  8. #8
    Registered User
    Join Date
    Sep 2009
    Location
    USA
    Posts
    63
    Quote Originally Posted by rags_to_riches View Post
    So your answer for a missing a semicolon is to just add semicolons everywhere? Why don't you actually read your ........ing book?
    "I FEEL" its so not cool man...you know they're many other ways to express that right?

Popular pages Recent additions subscribe to a feed