yet another dilemma...when they will end? :)

This is a discussion on yet another dilemma...when they will end? :) within the C++ Programming forums, part of the General Programming Boards category; Hello everyone! Let's cut the crap and jump right into this one...shall we? haha, anyways, ok...here's the question: the problem ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    153

    yet another dilemma...when they will end? :)

    Hello everyone!
    Let's cut the crap and jump right into this one...shall we? haha, anyways, ok...here's the question: the problem I'm faced with right now is I'm trying to write a program that will take a users dollar input (let's use the example 38000) and then make a loop that will have the following parameters of taxation -
    the first 5000 = 0% tax
    next 10000 = 10% tax
    next 20000 = 15%
    anything after 35000 = 20%

    so....if the user enters 38000...they would owe 5000 x 0.00 + 10000 x .010 + 20000 x 0.15 + 3000 ( this is 3000 b/c 38000 - 35000, just in case I'm being too vague) x 0.20...which should come out to 4600...ok, so I tried some if else statements and they started getting demanding hehe...I can't seem to figure out how to make a trickle down system where basically if the user enters 38000 it would break that down into 30000, 20000, 10000, 5000....something like that...ARG, too early haha...any help would be great, if I'm being too vague tell me...Thanks -Chap

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    Code:
    double tax( double income )
    {
        double temp;
        
        if( income < 5000.0 ) return 0.0;
        income -= 5000.0;
    
        if( income < 10000.0 ) return income * .10;
        else
        {
            temp =  10000.0 * .10;
            income -= 10000.0;
        }
    
        if( income < 20000.0 ) return temp + income * .15;
        else
        {
            temp += 20000.0 * .15;
            income -= 20000.0;
        }
    
        temp += income * .20;
    
        return temp;
    }
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    I would suggest you post code that you have attempted and that people do not blindly post a solution how is a person supposed to learn if they are given the answer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Modify to make Doubly Linked List
    By Dampecram in forum C Programming
    Replies: 10
    Last Post: 11-03-2008, 06:25 PM
  2. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. socket newbie, losing a few chars from server to client
    By registering in forum Linux Programming
    Replies: 2
    Last Post: 06-07-2003, 11:48 AM
  5. Next Question...
    By Azmeos in forum C++ Programming
    Replies: 3
    Last Post: 06-06-2003, 02:40 PM

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