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 is a characteristic of an effective problem statement? It is based on research. It contains outside information. It contai
Natasha_Volkova [10]

Answer:

It is based on research

Explanation:

An effective problem statement is a term often used in research operation to describe a statement that practically deals with the current issue that needs to be solved, situations or circumstances that require enhancement, or a drawback that must be solved, which demands critical insight and conscious analysis.

There are various characteristics of Effective problem statement, some of which are:

1. It should focus on the need for solving the problem

2. The ways in which the problem will be solved should be stated in a precise and concise manner

3. It should be based on the main objective of the statement.

Hence, in this case, the correct answer is "It is based on research."

8 0
3 years ago
What are tributaries
sukhopar [10]
Tributaries are rivers that flow into another river or another lake. Tributaries are common in any country. Tributaries are like roots of lakes that flows to somewhere else. It is like a distribution of water that scatters through streams and lands to a larger body of water.
5 0
3 years ago
Read 2 more answers
Discussion Topic
Elina [12.6K]

Robotics systems are systems that provide information based on artificial intelligence. These types of systems can be best employed in medical research, forensics, agriculture, etc.

<h3>What are robotic systems?</h3>

A robotic system is a use of a machine or the robots with artificial intelligence that are used to perform many various tasks like in automobile industries, health care, military, agriculture, etc.

A robotic system with computer vision can be used in medical treatment and research as they will help assist with complex surgeries, in agriculture to increase crop productivity and manage pests.

Therefore, robotics can be used in the military, food preparation, agriculture, health care, etc.

Learn more about robotic systems here:

brainly.com/question/12279369

#SPJ1

4 0
2 years ago
Edhesive silly questionsj
Alex17521 [72]
Mnhhbjhhhhdndkdjdjddnnxnx
4 0
3 years ago
Does -8 = -21?<br>[this is NOT a trick question]<br>Yes....?<br>No!​
Rudiy27

Answer:

No.

Explanation:

From my knowledge, negative 8 is 8 units to the left of zero, while 21 is 21 units to the left.

This means that they are two different negative numbers! If you see an equation like this, it would be labeled as false.

I'm quite sure I am correct, tell me so if otherwise! :)

#SpreadTheLove

8 0
3 years ago
Read 2 more answers
Other questions:
  • Sam's manager would like him to create and distribute copies of a budget report for each department. The budget report should sh
    8·2 answers
  • Design an algorithm for finding all the factors of a positive integer. For example, in the case of the integer 12, your algorith
    8·1 answer
  • What is a Photojournalist
    5·1 answer
  • If you press the key corresponding to letter A on the keyboard, what process is carried out inside the CPU to display the letter
    10·1 answer
  • Audio editing software contains several codecs that allow you to
    15·1 answer
  • According the Keown book, which Web-based personal financial planning website is known as "the best free way to manage your mone
    6·1 answer
  • Which practice is the safest way to sit at a desk while typing on the computer?
    12·1 answer
  • One problem with _______ is that often many copies of the same document are made. <br><br>HELPPP ​
    11·1 answer
  • Match the feature to its function.
    7·1 answer
  • Suppression of politically or socially unacceptable co
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!