In: Computer Science
Write a java program that calculates the total amount of money a person has made over the last year. The program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based on the total made. For this program, the federal tax will be 8.5% and the state tax will be 14.5%.
import java.util.Scanner;
public class Jobs {
public static final double FEDERAL_TAX=8.5;
public static final double STATE_TAX=14.5;
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
int i=1;
double n,gross=0;
//reading the salaries for all jobs
from user
//adding to sum of the
incomes
while(true) {
System.out.println("How much income you made through job "+i+"(-1
to quit)");
n=sc.nextDouble();
i++;
if(n==-1)
break;
gross+=n;
}
double
federalTax=getTax(gross,FEDERAL_TAX);
double stateTax=getTax(gross,
STATE_TAX);
double
net=gross-federalTax-stateTax;
System.out.println("Gross :
"+gross);
System.out.println("Federal Tax :
"+federalTax);
System.out.println("State Tax:
"+stateTax);
System.out.println("Net :
"+net);
}
//returns the tax on given amount with given
percentage
private static double getTax(double n, double tax)
{
return n * (tax/100);
}
}

Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me