1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
docker41 [41]
3 years ago
14

Write a java program to calculate employee pay using methods. There must be an overtime pay method and a straight pay method and

a print method. Using either scanner or JoptionPane, input the employee number, the hours worked, and the hourly pay for an employee. If the employee worked over 40 hours, call the overtime method, if not call the straight time method. Calculate the pay amount in one of the 2 methods. Call a third method to print the employee number and the pay amount.
Computers and Technology
1 answer:
Dimas [21]3 years ago
8 0

Answer:

Here is the code to solve this question written in Java programming language.

import java.util.Scanner;

class Main {

 public static void main(String[] args) {

   Scanner in = new Scanner(System.in);

   int hours;

   float hourly_fee, payment;

   System.out.println("Enter the amount of hours worked");

   hours = in.nextInt();

   System.out.println("Enter the fee per hour");

   hourly_fee = in.nextFloat();

   if(hours >= 0 && hours <= 40){

     payment = straighttime(hours, hourly_fee);

   }else{

     payment = overtime(hours, hourly_fee);

   }

   printPayment(payment);

 }

 public static float overtime(int hours, float fee){

   return(hours*fee*Float.parseFloat("1.25"));

 }

 public static float straighttime(int hours, float fee){

   return(hours * fee);

 }

 public static void printPayment(float payment){

   System.out.println("Your total payment is: "+payment);

 }

}

Explanation:

The commented code to solve this question is given below:

//Import the Scanner package to manage input from console.

import java.util.Scanner;

//Create the Main class

class Main {

 //Create the static void method to execute the logic of the program

 public static void main(String[] args) {

   /*

   Create an "in" object that manage the console inputs, declare the

   variables to manage the hours and the payment. "int" and "float"

   */

   Scanner in = new Scanner(System.in);

   int hours;

   float hourly_fee, payment;

   System.out.println("Enter the amount of hours worked");

   hours = in.nextInt();

   System.out.println("Enter the fee per hour");

   hourly_fee = in.nextFloat();

   // Evaluate the conditions to call overtime or straighttime given that the hours are greater than 40.

   if(hours >= 0 && hours <= 40){

     payment = straighttime(hours, hourly_fee);

   }else{

     payment = overtime(hours, hourly_fee);

   }

   printPayment(payment);

 }

 public static float overtime(int hours, float fee){

   /*

   This method is of type float and returns the total payment multplied by 1.25 that is the extra fee for overtime.

   */

   return(hours*fee*Float.parseFloat("1.25"));

 }

 public static float straighttime(int hours, float fee){

   /*

   This method is of type float and returns the total payment of straight hours.

   */

   return(hours * fee);

 }

 public static void printPayment(float payment){

   /*

   This methods print out in the console the total payment.

   */

   System.out.println("Your total payment is: "+payment);

 }

}

You might be interested in
Which relation is created with the primary key associated with the relationship or associative entity, plus any non-key attribut
konstantin123 [22]

Answer:

- Transform binary or unary M:N relationship or associative entity with its own key.

Explanation:

Transform binary relation is described as the method through which a decimal can easily be converted into binary while the unary relationship is described as a relationship in which both the two participants occurs from the same entity.

In the given case, 'transform binary or unary M:N relationship' can be created using 'the primary key linked with the relationship plus any non-key aspects of the relationship and the primary keys of the related entities' as it displays the existence of a relationship between the occurrences of a similar set of the entity i.e. associative entity here.

5 0
3 years ago
Which can be used to create a poll on a web page? <br>CSS<br>HTML <br>JavaScript <br>Text editor​
NeX [460]

Answer:

HTML can be used to create a poll on a web page.

4 0
2 years ago
compare a 4 core processor 1.3ghz 8 megabytes 16ram and 2 terabyte hard drive to a 2 core 3.9 ghz 2 megabyte cache 4gb ram and 2
deff fn [24]

Answer:

answer is in the question

Explanation:

4 0
2 years ago
If you often purchase items at the same e-tailer and do not have to type in your username and/or password, this probably means
tatyana61 [14]

Answer:

Explanation:

This probably means that your browser has saved your username and password into the browser's password manager. This usually occurs the first time you enter your username and password into a new website. The browser will detect this and request to save this information into the password manager. If you agree to do so it will save it and automatically enter this information when opening the site in the future.

3 0
3 years ago
Compared with a star topology, a hierarchical topology: a. is more effective at handling heavy but short bursts of traffic. b. a
Eduardwww [97]

Answer:

c. offers a great deal of network control and lower cost.

Explanation:

A network topology can be defined as a graphical representation of the various networking devices used to create and manage a network.

Compared with a star topology, a hierarchical topology offers a great deal of network control and lower cost.

4 0
3 years ago
Other questions:
  • A communications system connecting two or more computers is called a(n) ________.
    7·1 answer
  • 1. Given a sequential list with n numbers, represented in a one-dimensional array A) Write an algorithm to check if the list has
    14·1 answer
  • Which of these is the largest?<br> terabyte<br> exabyte<br> gigabyte<br> kilobyte<br> PLEASE HELP
    5·1 answer
  • Hat is the purpose of the domain name?
    7·2 answers
  • Assume you are given a boolean variable named isNegative and a 2-dimensional array of ints that has been created and assigned to
    8·1 answer
  • Please select the word from the list that best fits the definition Asking for review material for a test
    14·2 answers
  • 6
    9·1 answer
  • Firestick optimizing system storage and applications
    14·1 answer
  • Compare and contrast the advantages and disadvantages of a LAN to a WLAN.
    8·1 answer
  • Write a java code to print Multiplication Table Till 20
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!