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;
}