Java program an income tax program that 1. generate a random number of people in the range of (1-15); 2. ask the user to enter the amount of taxable income for each person, and then displays the tax due; 3. display the people with max value of taxes on the screen.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Java program
an income tax program that
import java.util.*;
public class Main
{
public static void main(String[] args) {
int maximum=15;
int minimum=1;
double max_tax=0;
Scanner sc=new Scanner(System.in);
int random_number=(int) (Math.random()*(maximum - minimum)) + minimum;//for generating random number
int[] a=new int[random_number];// to store income values
double[] tax=new double[random_number];// to store tax
//to read read input and calculate tax based on the slab
for(int i=0;i<random_number;i++)
{
System.out.println(" enter the taxable income");
a[i]=sc.nextInt();
if(a[i]<750)
{
tax[i]=a[i]*0.01;
}
else if(a[i]>=750 && a[i]<2500)
{
tax[i]=7.5+(a[i]-750)*0.02;
}
else if(a[i]>=2500 && a[i]<5000)
{
tax[i]=82.5+(a[i]-2500)*0.04;
}
else if(a[i]>=5000 && a[i]<8000)
{
tax[i]=142.50+(a[i]-5000)*0.05;
}
else
{
tax[i]=230.00+(a[i]-8000)*0.06;
}
System.out.println("the tax amount for "+i+1+" person is "+ tax[i]);
if(tax[i]>max_tax)
{
max_tax=tax[i];
}
}
System.out.println("the max tax amount is "+ max_tax);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images