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
For some reason my code is not printing in python. It doesn't give me an error is just not printing no thing shows up
svetoff [14.1K]

Answer:

Whats python? i might be able to help

Explanation:

5 0
3 years ago
Jim is in the market for a car that will last for the next 10 years and has saved up some money for the purpose of a car. What’s
Ratling [72]
I would imagine car would still be the best means , it's tough to define without knowing where he lives and how much he travels
8 0
3 years ago
What linux command displays the ip address and subnet mask?
Nookie1986 [14]
Type "ifconfig" at the terminal prompt, then press the "Enter" key. The IP address is labeled as "inet addr." The subnet is labeled as "Mask."

step 2

Type "netstat -r" at the command prompt, then press the "Enter" key to view the gateway address.

3 0
3 years ago
For each of the following SQL queries, for each relation involved,list the attributes that must be examined to compute the answe
Vlada [557]

Answer:

1. E.eid ,E.hobby, E.sal, E.did

2.E.eid , E.sal, E.hobby ,E.did , D.did, D.floor ,D.dname , D.budget.

3.E.eid , E.sal, E.hobby ,E.did , D.did, D.floor ,D.dname , D.budget.

4.E.eid , D.dname

Explanation:

The attributes that are examined for the query are the attributes of the table that are mentioned in the select statement and where clause.

So according to first query we are working on all attribues of Emp table so all of the attributes of Emp table are examined.In second query we selecting all attributes of both the tables hence all attributes of both the table and same in the next query.

In fourth query though the query is not complete where clause is missing but we have eid from Emp and dname from Dept tables for sure and the attributes mentioned in where clause will also be present.

7 0
3 years ago
The title element in the head section of an HTML document specifies the text
bagirrra123 [75]

Answer: c. that's displayed in the title bar of the browser

Explanation:

The title element in the html write up is used to describe the title of the work that is been carried out.

It has the format <title></title>, the title name is indicated between the opening and closing title tag.

The title does not display on the main page of the Web user's display, but it can be seen on the title bar of the Web browser.

The title element help Web user to have an idea of what a Web page is about.

7 0
3 years ago
Other questions:
  • ___ is the branch of computer science that explores techniques for incorporating aspects of intelligence into computer systems.
    5·1 answer
  • To decrease the size of text so it will fit into a text box without overflowing, select the
    14·2 answers
  • Windows Live SkyDrive is an example of _____ storage.
    13·1 answer
  • What is an effective way to display calculations in a Word document
    7·2 answers
  • Do you think that people have a “right” to remain anonymous online? Why or why not?
    6·1 answer
  • echnician A says that underinflation can increase the rolling resistance of a tire. Technician B says that underinflation can ca
    9·1 answer
  • The shell of a document that may be used over and over in desktop publishing is called a
    9·1 answer
  • Which type of mic is durable, versatile and does not rely on power?
    14·2 answers
  • What is a characteristic of high-level languages?
    15·1 answer
  • When viewing an e-book section of an assignment in launchpad, you can return to your main course page at any time by clicking th
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!