Sie sind auf Seite 1von 2

CPSC 155 - COMPUTER PROGRAMMING FALL 2013 ASSIGNMENT 5 Due: October 7 You will be creating a program that uses

several functions to divide up the work into smaller pieces. This program will calculate how much money the user owes in taxes based on the users income, and whether the user is married. These calculations are based on a very simple tax model: if the user is single and earns up to $40,000 (what well call the income threshold), the user will pay 25% of that incomes as taxes. If the user earns more than the income threshold, the user will pay 25% times the income threshold plus 35% of any income earned above that. For example, for a single individual earning $50,000, taxes will be 25% x $40,000 + 35% * $10,000 = 0.25 x $40,000 + 0.35 x $10,000 = $13,500. For married couples, the threshold should be doubled to $80,000, but the tax rates will be the same (25% below the threshold, 35% on income above it). The functions you will be writing are: inputName Parameters: The Scanner variable being used for input Returns: A String with the users name This function should display a prompt asking for the users name, get the name from the user, and return that name. You may assume that the users name is one word (like Mark). inputIncome Parameters: The Scanner variable being used for input Returns: A double with the users annual income This function should display a prompt asking for the users annual income, and get that income from the user, as a double. inputMarried Parameters: The Scanner variable being used for input Returns: A char, either y or n, whether the user is married This function should display a prompt asking if the user is married. If the user enters something other than y or n, this should return n, otherwise return the character that the user typed in. calculateThreshold Parameters: A char, indicating whether the user is married Returns: A double that is the users income threshold incomeBelowThreshold Parameters: Two doubles: the users income and the income threshold Returns: The amount of income that will be taxed at 25%. Either the users income, if thats less than the threshold, or the threshold itself if its more than the income. incomeAboveThreshold Parameters: Two doubles: the users income and the income threshold Returns: The amount of money that will be taxed at 35%. Either 0, if the users income is less than the threshold or, if its more than the threshold, the amount more than the threshold.

taxBelowThreshold Parameters: Income below threshold as a double Returns: The taxes that should be paid on the amount of money below the income threshold (a double) taxAboveThreshold Parameters: Income above threshold as a double Returns: The taxes that should be paid on the amount of money above the income threshold (a double) totalTaxes Parameters: taxBelowThreshold and taxAboveThreshold as doubles Returns: The total amount of taxes paid displayResults Parameters: name as a String, marital status as a char, income as a double, total taxes as a double Returns: void This should display each of the four values passed in (with proper text, explaining what each value is to the user). The doubles should be formatted with two decimal places, and the marital status should be displayed nicely as either Single or Married. For example: Name: Maria Marital Status: Single Income: 50000.00 Taxes: 13500.00 Finally, youll be writing a main function. This function should not do any of the calculations itself, but should call the other functions to perform those calculations. The main function should use variables as necessary to remember those results. The main function should be able to work perfectly if it calls the other functions in the order given. Programming Style You must use correct programming style, including appropriate variable and method names, proper indentation, and comments in the code. About 10% of the final grade will be based on the programming style. Submitting the Program Submit a printout of your program, and a printout of the output your program generates for each of the three given input sequences (Run your program & copy the output screen three times). Use Word to print the output. Your program must include the following documentation (comments) at the top: 1) Your name 2) The date 3) The assignment number 4) A brief description of what the program does Run the program twice using the following input data: 1) Maria, $60,000, 0 2) Steve $90,000, 1

Das könnte Ihnen auch gefallen