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

hey guys, i am begginer programer and working on java program. i wrote program t

ID: 3702349 • Letter: H

Question

hey guys, i am begginer programer and working on java program.
i wrote program that asks ID, how many hours does person work and what is hourly wage and it prints out the result(salery). if Id is less or equal 0 program stops. (also is salery is less that 300 it has taxes 0.03% if it is between 300 and 350 taxes are 0.04% and if salery is up to 300 taxes are 0.05%)
I am using loops to repead questions many times. and loop stops after ID is less or equal 0. when loop ends it also outputs how many time users does user input.
all this is done by me. but one question is to print out the total of the salerys of each employs. that is where i am stuck and also there is one question about printf.

here is a question (Now add to your program printf statements so that the hours worked and salary will print with two decimal places. Create fixed columns for each piece of data (ID, hors worked, hourly rate and total salary). Numbers should be right adjusted so the dollars and cents line up. Run the program again with the same data and see what the output looks like now. Print the program and the output)

so i need help to print out total salerys after program ends, and use printf.

here is my code what i have so far.

package lab4;
import java.util.Scanner;


public class Lab4 {

  
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int Id;
double wage;
double hours;
double salery;
int count =0;
  
  

  
  
System.out.println("what is your Id " );
Id = input.nextInt();
System.out.println("what is your wage ");
wage =input.nextDouble();
System.out.println("How many hour did you work ");
hours=input.nextDouble();
salery = wage*hours;


if (Id<1)
System.out.println("Id must be at least 1");
if ((Id>1) && (salery<300))
System.out.println("amount for ID "+Id +"is under 300 and salary is " +salery +" taxes are " + salery*0.03);

if ((Id>1) && (salery>300 && salery <350))
System.out.println("amount for ID "+Id +"is between 300 and 350 and salery is " + salery +" and taxes are "+ salery *0.04);
if ((Id>1) && (salery >350))
System.out.println("amount for Id "+Id +"is more 350 and salery is " + salery +" and taxes are "+ salery *0.05);


  
  
  
  
  
while (Id > 1){
System.out.println("what is your Id " );
Id = input.nextInt();
System.out.println("what is your wage ");
wage =input.nextDouble();
System.out.println("How many hour did you work ");
hours=input.nextDouble();
salery = wage*hours;


if (Id<1)
System.out.println("Id must be at least 1");
if ((Id>1) && (salery<300))
System.out.println("amount for Id"+Id +"is under 300 and salary is " +salery +" taxes are " + salery*0.03);

if ((Id>1) && (salery>300 && salery <350))
System.out.println("amount for Id "+Id +"is between 300 and 350 and salery is " + salery +" and taxes are "+ salery *0.04);
if ((Id>1) && (salery >350))
System.out.println("amount for ID "+Id +"is more 350 and salery is " + salery +" and taxes are "+ salery *0.05);
count++;


  
}
System.out.println( "user input "+count++ +" times and sum up and all salerys are " );


}   
}

Explanation / Answer

CalTaxBasedOnSalary.java

import java.util.Scanner;

public class CalTaxBasedOnSalary {

public static void main(String[] args) {

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner input = new Scanner(System.in);

//Declaring variables

int Id;

double wage;

double hours;

double salery,tax = 0,totalSalary=0.0;

int count = 0;

//Getting the input entered by the user

System.out.println("what is your Id ");

Id = input.nextInt();

/* This while loop continues to execute

* until the user enters a valid Id

*/

while(Id>0)

{

//Getting the input entered by the user

System.out.println("How many hour did you work ");

hours = input.nextDouble();

System.out.println("what is your wage ");

wage = input.nextDouble();

salery = wage * hours;

//Based on the salary calculate tax

if(salery<300)

{

tax=salery * 0.03;

System.out.printf("amount for ID %d is under 300 and salary is %.2f taxes are %.2f ",Id,salery,tax);

}

else if(salery>=300 && salery<=350)

{

tax=salery * 0.04;

System.out.printf("amount for ID %d is between 300 and 350 and salery is %.2f and taxes are %.2f ",Id,salery,tax);

}

else if(salery>350)

{

tax=salery * 0.05;

System.out.printf("amount for Id %d is more 350 and salery is %.2f and taxes are %.2f ",Id,salery,tax);

}

//calculating total salary

totalSalary+=(salery+tax);

count++;

System.out.println("what is your Id ");

Id = input.nextInt();

}

System.out.printf("User input %d times and sum up and all salerys are %.2f ",count,totalSalary);

}

}

____________________

Output:

what is your Id
12
How many hour did you work
40
what is your wage
12
amount for Id 12 is more 350 and salery is 480.00 and taxes are 24.00
what is your Id
5
How many hour did you work
35
what is your wage
10
amount for ID 5 is between 300 and 350 and salery is 350.00 and taxes are 14.00
what is your Id
3
How many hour did you work
30
what is your wage
14
amount for Id 3 is more 350 and salery is 420.00 and taxes are 21.00
what is your Id
-1
User input 3 times and sum up and all salerys are 1309.00

______________Thank You