Hi My name is PJ.
I am a adult student.
I have read the rules regarding homework for those who are not willing to help themselves and i agree, but i have tried for the last few days to work this out and cant understand what i am doing wrong, if someone is kind enough to help and point me in the right direction, i would be very greatful. Below is the C# code i have. The program is meant to display the different tax brackets for the income within the amounts shown in the code below.
It's meant to display >$38000.00 shows 19.5%
>$60000.00 shows 33.0%
<$60001.00 shows 39.0%
No declaration shows 45.0% (sorry this hasnt been added yet). It displays the answer in a dollar form and does not show the right answer. Please explain what i have done and what i need to do to correct this. If you answer this, thankyou so much for taking the time to help. I am a first year student who is getting stuck with this.
Code posted with comments (// out) below:
string strtaxableIncome;
decimal dectaxableIncome;
decimal dectax;
// Display "Plaese enter Income Tax"
Console.WriteLine("Please enter Income Tax");
//Displap dollar sign
Console.Write("$");
// Read taxableIncome
strtaxableIncome = Console.ReadLine();
// Additional steps to convert string to decimal
dectaxableIncome = decimal.Parse(strtaxableIncome);
// Set tax = 0
dectax = 0m;
// If (taxableIncome <= 38000) Then
if (dectaxableIncome <= 38000)
{
// Calculate tax (tax = 19.5% of 38000)
dectax = dectaxableIncome * 19.5m / 100;
}
// End If
// If taxableIncome is more than 38000 and less than or equal to 60000 Then
if (dectaxableIncome > 38000 && dectaxableIncome <= 60000)
{
// Calculate tax (tax = 19.5% of 38000 + 33% of 60000-38000)
{
dectax = dectaxableIncome * 19.5m / 100;
dectax = dectax + dectaxableIncome * 33m / 100;
}
// End If
// If taxableIncome is more than 60000 Then
if (dectaxableIncome > 60000)
// Calculate tax (tax = 19.5% of 38000 + 33% of 60000-38000 + 39% of taxableIncome – 60000)
{
dectax = dectaxableIncome * 19.5m / 100;
dectax = dectax + dectaxableIncome * 33m / 100;
dectax = dectax + dectaxableIncome * 39m / 100;
}
// End If
// Display tax
Console.Write("$");
Console.Write(dectax);
// Keep window open
Console.ReadKey();