Ask Question

create a Java program that prompt the user to enter a number of hours, wages, over time factor, then your program should calculate the employee total wages. Make sure your program can calculate the over time and regular wages if number of hours are great than 40 hours. Use 1.5 for over time factor. Make sure your Java code has comments showing declarations and description of your variables.

+5
Answers (1)
  1. 18 February, 08:28
    0
    The program to the given question as follows:

    Program:

    import java. util.*; / /import package for user input.

    public class Main / /defining class Main

    {

    public static void main (String[] as) / /defining main method

    {

    final double over_time_factor = 1.5; / /define final variable

    double number_Of_hours, wages, total_Wages=0; / /defining variables

    System. out. println ("Enter hours and wages rate:"); / /print message

    Scanner obc = new Scanner (System. in); / /creating Scanner class object for user input

    number_Of_hours = obc. nextDouble (); / /taking input

    wages = obc. nextDouble (); / /taking input

    if (number_Of_hours>40) / /check condition if number_Of_hours greter then 40

    {

    total_Wages=40*wages + (number_Of_hours-40) * wages*over_time_factor; / /calculate value

    }

    else / /else part

    {

    total_Wages = number_Of_hours*wages; / /calculate total_Wages

    }

    System. out. println ("Total Wages: $"+total_Wages); / /print value

    }

    }

    Output:

    Enter hours and wages rate:

    12

    3

    Total Wages: $36.0

    Explanation:

    In the above java program, the package is first imported into the user input and then the class is defined and inside this, the main method is defined, that defines a double type final variable "over_time_factor" is defined that holds a value "1.5", Then double type variable is defined that are " number_Of_hours, wages, and total_Wages", in which first two variables are used for taking input from the user and the third variable is used to calculate their values. After taken input from the user, the conditional statement is used that can be defined as follows:

    The if block, checks the variable "number_Of_hours" value is greater than 40 it will calculate over_time_factor value that is held by total_Wages variable. In else block, it will multiply the user input value that is store in total_Wages variable. At the end of the conditional statement, the print function is used that prints total_Wages variable value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “create a Java program that prompt the user to enter a number of hours, wages, over time factor, then your program should calculate the ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers