131k views
25 votes
in Java programming Design a program that will ask the user to enter the number of regular working hours, the regular hourly pay rate, the overtime working hours, and the overtime hourly pay rate. The program will then calculate and display the regular gross pay, the overtime gross pay, and the total gross pay.

User Bidifx
by
3.4k points

1 Answer

13 votes

Answer:

In Java:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

int regularhour,overtimehour;

float regularpay,overtimepay;

Scanner input = new Scanner(System.in);

System.out.print("Regular Hour: ");

regularhour = input.nextInt();

System.out.print("Overtime Hour: ");

overtimehour = input.nextInt();

System.out.print("Regular Pay: ");

regularpay = input.nextFloat();

System.out.print("Overtime Pay: ");

overtimepay = input.nextFloat();

float regulargross = regularhour * regularpay;

float overtimegross = overtimehour * overtimepay;

float totalgross = regulargross + overtimegross;

System.out.println("Regular Gross Pay: "+regulargross);

System.out.println("Overtime Gross Pay: "+overtimegross);

System.out.println("Total Gross Pay: "+totalgross);

}

}

Step-by-step explanation:

This line declares regularhour and overtimehour as integer

int regularhour,overtimehour;

This line declares regularpay and overtimepay as float

float regularpay,overtimepay;

Scanner input = new Scanner(System.in);

This prompts the user for regular hour

System.out.print("Regular Hour: ");

This gets the regular hour

regularhour = input.nextInt();

This prompts the user for overtime hour

System.out.print("Overtime Hour: ");

This gets the overtime hour

overtimehour = input.nextInt();

This prompts the user for regular pay

System.out.print("Regular Pay: ");

This gets the regular pay

regularpay = input.nextFloat();

This prompts the user for overtime pay

System.out.print("Overtime Pay: ");

This gets the overtime pay

overtimepay = input.nextFloat();

This calculates the regular gross pay

float regulargross = regularhour * regularpay;

This calculates the overtime gross pay

float overtimegross = overtimehour * overtimepay;

This calculates the total gross pay

float totalgross = regulargross + overtimegross;

This prints the regular gross pay

System.out.println("Regular Gross Pay: "+regulargross);

This prints the overtime gross pay

System.out.println("Overtime Gross Pay: "+overtimegross);

This prints the total gross pay

System.out.println("Total Gross Pay: "+totalgross);

User Matthew Dalton
by
3.8k points