Lab If-Else
package ifelse;
public class ifelse {
public static void main(String[] args)
{
double netIncome=30000,tax,fivePercentTax,tenPercentTax;
if(netIncome <= 15000)
tax=0;
else if((netIncome > 15000)&&(netIncome <= 30000))
tax=(0.05*(netIncome-15000));
else
{
fivePercentTax=0.05*15000;
tenPercentTax=0.10*(netIncome-30000);
tax=(fivePercentTax+tenPercentTax);
}
System.out.println("Tax due = "+tax);
}
}
public class ifelse {
public static void main(String[] args)
{
double netIncome=30000,tax,fivePercentTax,tenPercentTax;
if(netIncome <= 15000)
tax=0;
else if((netIncome > 15000)&&(netIncome <= 30000))
tax=(0.05*(netIncome-15000));
else
{
fivePercentTax=0.05*15000;
tenPercentTax=0.10*(netIncome-30000);
tax=(fivePercentTax+tenPercentTax);
}
System.out.println("Tax due = "+tax);
}
}
0 Comments:
張貼留言
<< Home