At Westonci.ca, we make it easy to get the answers you need from a community of informed and experienced contributors. Our platform provides a seamless experience for finding reliable answers from a knowledgeable network of professionals. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.

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.

Sagot :

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);

 

}

}

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);

We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.