View Single Post
  #6 (permalink)  
Old 07-31-2007, 01:06 PM
e_as're e_as're is offline
Member
 
Join Date: Jul 2007
Posts: 7
e_as're is on a distinguished road
this is what ive got so far and its not very good:

public class Q2Program {
public void start(){

// User types in income to nearest dollar and program
// responds with tax owing, and tax as % of income
// Ignore the under $9,880 rebate
// Assume all income counts for the "under $38,000" rebate
// Show with, and without, student loan owing for the entire year
// Use double arithmetic for calculations, but..
// Display money amounts rounded to nearest dollar
// Make use of the following constants for the tax rates

final double LOW_TAX_RATE = 0.195;
final double MID_TAX_RATE = 0.33;
final double TOP_TAX_RATE = 0.39;
final double REBATE_RATE = 0.045;
final double PENALTY_RATE = 0.015;
final double LOAN_RATE = 0.1;

/* Note that a professional program would also use constants for the
various income levels, but that would make this exercise a bit
cumbersome for beginners */

// Get income from the user
System.out.print("Type in total income to nearest dollar: ");
String income = Keyboard.readInput();

double income<38000 = Math.min(income, 38000);
System.out.print("On a income of: $" + income<38000);

double income>38000 = Math.max(0,income - 38000);
System.out.print("On a income of: $" + income>38000);

double income>38000<60000 = ?????????????? Math.max(0, income, - 38000, 60000);
System.out.print("On a income of: $" + income>38000<60000);

double income>60000 = Math.max(0, income - 60000);
System.out.print("On a income of: $" + income>60000);


// Calculate income tax

// find tax on income up to $38,000 at 19.5%
double income<38000Tax = income<38000 * LOW_TAX_RATE;
System.out.print(" Income tax is: $" + income<38000Tax);

// find tax on income between $38,000 and $60,000 at 33%
double income>38000<60000Tax = income>38000<60000 * MID_TAX_RATE;
System.out.print(" Income tax is: $" + income>38000<60000Tax);

// find tax on income over $60,000 at 39%
double income>60000Tax = income>60000 * TOP_TAX_RATE;
System.out.print(" Income tax is: $" + income>60000Tax);

// Calculate tax rebate
// find rebate on income up to $9500 at 4.5%
double taxRebate = 9500 * REBATE_RATE;

// find penalty on rebate for income between $9500 and $38,000 at 1.5%
double penaltyRebate = (income - 9500) * PENALTY_RATE;

// calculate net rebate
double netRebate = (taxRebate - penaltyRebate);

// calculate total income tax
double totalIncomeTax<38000 = (income<38000 - income<38000Tax);
double totalIncomeTax>38000<60000 = (income>38000<60000 - income>38000<60000Tax);
double totalIncomeTax>60000 = (income>60000 - income>60000Tax);

// Calculate percentage of income
double percentageOfIncome<38000 = ((income<38000 - totalIncomeTax<38000) * 100);
double percentageOfIncome>38000<60000 = ((income>38000<60000 - totalIncomeTax>38000<60000) * 100);
double percentageOfIncome>60000 = ((income>60000 - totalIncomeTax>60000) * 100);

// Calculate student loan tax
double studentLoanTax = (income - 17160) * LOAN_RATE;

// Calculate total taxes, with and without loan;
double totalTax = (?????????????income tax - netRebate);
double totalTaxInclStudentLoan = (totalTax + studentLoanTax);

// Display tax owing and rates
System.out.print(" With rebate of: " + netRebate);
System.out.print(" Giving total tax of: " + totalTax);
System.out.print(" Which is: " + percentageOfIncome<38000" of income");
System.out.print(" Which is: " + percentageOfIncome>38000<60000" of income");
System.out.print(" Which is: " + percentageOfIncome>60000" of income");
System.out.print("With a student loan:");
System.out.print(" Loan repayment is an additional: " + studentLoanTax);
System.out.print(" For total \"tax\" of: " + totalTax);
System.out.print(" Which is: " + percentageOfIncome<38000 + " of income");
System.out.print(" Which is: " + percentageOfIncome>38000<60000 + " of income");
System.out.print(" Which is: " + percentageOfIncome>60000 + " of income");

//Use the method Math.round()to convert a double value to the nearest whole dollar value.

}

}
Reply With Quote