Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a part of program I wrote in Java. I was wondering if anyone can help me

ID: 3645124 • Letter: T

Question

This is a part of program I wrote in Java.
I was wondering if anyone can help me rewrite the code.
I'm using "if else" to get different tax rates of 3 different income ranges.
I now wanna make it able to calculate 30 different tax rates using array and loop instead.

//Request input from the user
//Calculate Tax Rate
String grossIncomeString = JOptionPane.showInputDialog("Enter your gross income: ");
grossIncome = Double.parseDouble(grossIncomeString);
double taxrate;
if (grossIncome <= 10000)
{
taxrate = 0.18;
}
else if (grossIncome <= 50000)
{
taxrate = 0.31;
}
else
{
taxrate = 0.40;
}

Explanation / Answer

I'm assuming you want different income levels too? int taxRates = {rate1, rate2, rate3,.....,rate30} //you'll have to manually put these in however you want, or ask the user. int incomeLevels = {level1, level2, ....,level29}//you dont need the 30th level, since anything higher will be taxed at rate 30 taxRate = 0; for(int i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote