think I have a grasp on all the concepts. I think another pair of eyes would be beneficial. TIA!
Problem A: Aruba Taxes. Objectives: Using Decision Structures and appropriate testing.
The taxes in Aruba are based on annual income with the following formula. For incomes of 10,000 guilders or less, the taxes = income * .02. For incomes more than 10,000 but less than 25,000, citizens pay 2% on the first 10,000 and 3% on the rest. For incomes $25,000 but less than $75,000 citizens pay 3% on the first 25,000 and 4% on the rest. For incomes $75,000 or more, citizens pay 5% on all earnings. For example, the taxes on an income of $12,000 guilders would be: $260. Non-resident citizens get a 1% discount on the amount of taxes owed.
Create a class that represents an Aruba citizen with attributes for name, income, and residency status (use a boolean variable for this last attribute). In addition to the gets and sets for each attribute, make a constructor that accepts the name, income, and residency status when creating the object and a method that returns the amount of taxes owed. Create a driver program that will read in annual incomes, create an object representing the citizen, and print out the tax amount owed.
Use the following data for the execution you turn in:
Francisco deMiranda: $35,000, resident
Alonso deOjeda: $63,000, resident
Halevi Maduro: $23,000, residentFransic
Prince Stuyvesant: $255,250, resident
Queen Beatrix: $105,000, non-resident
This is what I have so far:
public class ArubaTaxes { private String name; // Your name private double income; // Your income private boolean residency; //Do you live here or not? public void setName(String n) { name = n; } public void setIncome(double ic) { income = ic; } public void setResidency(boolean res) { residency = res; } public String getName(String name) { return name; } public double getIncome(double income) { double taxes; if (income < 10000) taxes = income * .02; else if (income > 10000 && income < 25000) taxes = (income * .03) - (income * .02); else if (income > 25000 && income < 75000) taxes = (income * .04) - (income * .03); else if (income > 75000) taxes = income * .05; } public boolean residency(boolean residency) { boolean resident; if (residency = false) taxes = totalOwed * .01; else taxes = totalOwed; } }