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
A continuous and differentiable function f(x) with the following properties: f(x) is decreasing at x=−5 f(x) has a local minimum
butalik [34]

The continuous and differentiable function where f(x) is decreasing at x = −5 f(x) has a local minimum at x = −2 f(x) has a local maximum at x = 2 is given as: y = 9x - (1/3)x³ + 3.

<h3>What is a continuous and differentiable function?</h3>

The continuous function differs from the differentiable function in that the curve obtained is a single unbroken curve in the continuous function.

In contrast, if a function has a derivative, it is said to be differentiable.

<h3>What is the solution to the problem above?</h3>

It is important to note that a function is differentiable when x is set to a if the function is continuous when x = a.

Given the parameters, we state that

f'(5) < 0; and

x = -5

The local minimum is given as:
x = -3;

the local maximum is given as

x = 3

Thus, x = -3 ; alternatively,

x = 3.  With this scenario, we can equate both to zero.

Hence,

x + 3 = 0;

3-x = 0.

To get y' we must multiply both equations to get:

y' = (3-x)(x + 3)

y'   = 3x + 9 - x² - 3x

Collect like terms to derive:

y' = 3x - 3x + 9 - x²; thus

y' = 9-x²

When y' is integrated, the result is

y = 9x - (x³/3) + c

Recall that

F (-5) < 0

This means that:

9 x -5 - (-5³/3) + c < 0
⇒ -45 + 125/3 + c <0
⇒ -10/3 + c < 0

Collecting like terms we have:
c < 10/3; and

c < 3.33


Substituting C into

f(x) = 9x - x³/3 + c; we have

f(x) = 9x - x³/3 + 3, which is the same as  y = 9x - (1/3)x³ + 3.

Learn more about differentiable functions at:
brainly.com/question/15047295
#SPJ1

7 0
2 years ago
Which of the following is the core communications protocol for the internet? telnet ftp tcp/ip ssl
inna [77]
Tcp/ip is the core communication protocol for the internet
4 0
3 years ago
Write a program that reads a file name from the keyboard. The file contains integers, each on a separate line. The first line of
Sindrei [870]

Answer:

Explanation:

import java.util.Scanner;

import java.io.*;

public class ArrayProcessing

{

public static void main(String[] args) throws IOException

{

Scanner kb = new Scanner(System.in);

String fileName;

System.out.print("Enter input filename: ");

fileName = kb.nextLine();

File file = new File(fileName);

if(!file.exists())

{

System.out.println("There is no input file called : " + fileName);

return;

}

int[] numbers = inputData(file);

printArray(numbers);

}

public static int[] inputData(File file) throws IOException

{

Scanner inputFile = new Scanner(file);

int index = 1;

int size = inputFile.nextInt();

int[] values = new int[size];

while(inputFile.hasNextInt() && index < values.length)

{

values[index] = inputFile.nextInt();

index++;

}

inputFile.close();

return values;

}

public static void printArray(int[] array)

{

int count = 1;

for (int ndx = 1; ndx < array.length; ndx++)

{

System.out.printf("%5.f\n", array[ndx]);

count++;

}

if(count == 10)

System.out.println("");

}

}

4 0
3 years ago
The assignment operator has left-to-right-to-left associativity, which means that the value of the expression to the left of the
postnew [5]

Answer:

The given statement is false statement.

Explanation .

  • The assignment is assigning the value to the variable or we can say that it will also be used to initialize the variable The "=" is the symbol of the assignment operator.
  • For example

        int r=90, The value of variable 90 is assigned to 90.

  • The associativity, of assignment, is always right to left which means The right-hand side is firstly evaluated then it will be assigned in left-hand side variable or expression.  

4 0
3 years ago
Discus four importance of applications software​
AlladinOne [14]

Answer:

l hope this helps Good luck.

6 0
3 years ago
Other questions:
  • 1. A video card on a modem motherboard would run best in which type of slot?
    10·1 answer
  • What does the Sort feature do with a database
    13·1 answer
  • Which function should be used to display a value based on a comparison?
    11·1 answer
  • Working at a ski resort in the mountains has its own unique security issues. Kenny is the chief information officer for Sundance
    10·1 answer
  • What lets you do many things, like write book reports and stories?
    15·1 answer
  • Which communication technology should you use if you need to connect three offices which are all within 3 miles of each other at
    6·1 answer
  • Anyone know the answer I need help
    12·1 answer
  • Choose the correct term to complete the sentence.
    12·1 answer
  • What is the value of the variable named result after the following code executes?
    10·1 answer
  • A Product Manager has been given responsibility for overseeing the development of a new software application that will be deploy
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!