Calculating Taxes

This is a discussion on Calculating Taxes within the C Programming forums, part of the General Programming Boards category; I am neding some assistance with this samll problem that I am having. I am trying to simply Some food ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    5

    Angry Calculating Taxes

    I am neding some assistance with this samll problem that I am having. I am trying to simply

    Some food items and all non-food items are subject to a statewide sales tax and local district taxes. Due to differences in district taxes, each store uses a different tax rate.
    Del Mar - 7.25%
    Encinitas - 7.5%
    La Jolla - 7.75%
    Expected Results/Impact when completed:

    C program that displays the sales tax amount for each store location for a purchase amount of $125.00.

    But after doing it all it will not show anything on the excute screen. Any advice?
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        //Declare Variables
        float fsubtotal, taxdelmar, taxencinitas, taxlajolla;
        float fCost;//calculation operator
        int iResponse = 0;
        
        fCost = 0;
        fsubtotal=125.00;
        taxdelmar=.0725;
        taxencinitas=.0750;
        taxlajolla=.0775;
        
         getchar();
        
        return 0;
    Last edited by Salem; 10-22-2008 at 11:42 AM. Reason: Added code tags

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,415
    Moved to its own thread.

    At a glance, the reason why it will not show anything is because you did not print anything (not to mention that you did not compute anything, either).

    Oh, and please post your well indented code in [code][/code] tags. By the way, why do you return 5 instead of 0 when main exits successfully?
    Last edited by laserlight; 10-22-2008 at 09:06 AM. Reason: exists -> exits
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    You would just have to think how you would mathematically calculate this without programming. Do that, and maybe store its result in a variable, then use printf() to print it out. Also why return 5? Should be return 0.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    5

    tax calculator

    Sorry it is only my second week in a programming class and i am tring to figure ths all out but you dont have to help but you can keep your negative comments to yourself

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,415
    i am tring to figure ths all out
    Okay, so you understand that the main reason why you are getting no output is that you did not print any output?

    you can keep your negative comments to yourself
    So far, no one has posted any negative comments.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    5

    sales tax

    yes i understand that is why I want it so that it will output the information. i added the printf as told and put in the other information and came up with same thing. sorry second week in a computer class ever just trying to get my feet wet.

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    5
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        //Declare Variables
        float fsubtotal, taxdelmar, taxencinitas, taxlajolla;
        float fCost;//calculation operator
        int iResponse = 0;
        
        fCost = 125.00;
        fsubtotal = 125.00;
        taxdelmar = .0725;
        taxencinitas = .0750;
        taxlajolla = .0775;
        
       
        printf("\n\tKudler Fine Foods 'Sales Tax Calculator'\n"); 
        printf("125*.0725\n"); 
         getchar(); 
        
    }

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So that just prints literally "125*.0725", it does not print the value of the calculation. I would guess you need to reread your notes (or maybe someone else's notes) on printf, especially the part where they talk about %.

  9. #9
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,648
    You can always just search this forum for University of Phoenix, La Jolla, whatever. We get questions on this U of P assignment every six months or so.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculating : high numbers
    By MiraX33 in forum C++ Programming
    Replies: 9
    Last Post: 06-08-2006, 11:08 PM
  2. Calculating CPU Usage
    By vitaliy in forum Linux Programming
    Replies: 3
    Last Post: 08-21-2005, 09:38 AM
  3. Recursion
    By Lionmane in forum C Programming
    Replies: 11
    Last Post: 06-04-2005, 12:00 AM
  4. Taking input while calculating
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 07-12-2002, 04:47 PM
  5. Calculating window sizes
    By Mox in forum Windows Programming
    Replies: 3
    Last Post: 11-08-2001, 08:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21