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]
4 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]4 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
What is the function of the operating system of a computer?
irina1246 [14]

Answer:

It allows the CPU to communicate with input and output devices.

Explanation:

Plzzzzzzzzzzzzz give me brainiest

6 0
3 years ago
You attempt to telnet to system 192.168.1.240. You receive the following message: "Connecting To 192.168.1.240...Could not open
Serjik [45]

Answer:

firewall

Explanation:

The firewall could be used to protect the network from unauthorised access.Usually an ip could be whitelisted so it could transfer packets between allowing it connect through.

3 0
3 years ago
In both direct flooding attacks and _____ the use of spoofed source addresses results in response packets being scattered across
Natali5045456 [20]

Answer:

SYN spoofing attacks.    

Explanation:

The Spoofing attack is used to access the personal information it is distributed the  viruses through infected links or file .The spoofing attacks has redistributed the traffic and the flow control in the denial-of-service attacks.

The SYN spoofing attacks is used the spoofed source in the result of giving response to packet The Spoofing attack  is distributed  across the Internet also it is detectable

6 0
3 years ago
In the early days of photography, cameras were limited to professional photographers because of the knowledge needed to work the
FinnZ [79.3K]
True they had to be developed in a special way in a dark room with several chemicals. 
3 0
4 years ago
Read 2 more answers
Why is information so important in our lives
GREYUIT [131]
Information is very important because it helps us as a society make decisions. Decisions are impossible without information, and we are constantly seeking information in everything we do. Information is important in decreasing our sense of doubt and uncertainty as well.
5 0
3 years ago
Read 2 more answers
Other questions:
  • What problem does chlorofluorocarbon (CFC) create?
    5·1 answer
  • ________________ is a new method or idea or product or enhancement or other means of adding value to an existing product, such t
    14·1 answer
  • Which of the following statements is true of nonroutine messages? a. They typically concern novel events. b. They are best commu
    5·1 answer
  • How do you launch windows on a computer?
    14·1 answer
  • 15. The most efficient way to perform data entry is to keep your hands on the keyboard and press _______ to move to the next cel
    13·1 answer
  • Which audio media can be directly sent to the subscribers through an RSS feed?
    6·1 answer
  • hãy lựa chọn một doanh nghiệp kinh doanh theo loại hình siêu thị việt nam em hãy tìm hiểu doanh nghiệp và thực hiện theo yêu cầu
    10·1 answer
  • What is the default return type of a method in Java language?
    9·2 answers
  • Can someone please help me with this ,it is my assignment of technology and agriculture year 8
    5·1 answer
  • write pseudocode to represent the logic of a program that allows the user to enter two values. The program outputs the sum of an
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!