Ask Question
25 October, 17:04

Write a method named pay that accepts two parameters: a real number for a TA's salary, and an integer for the number of hours the TA worked this week. The method should return how much money to pay the TA. For example, the call pay (5.50, 6) should return 33.0.

The TA should receive "overtime" pay of 1 ½ normal salary for any hours above 8. For example, the call pay (4.00, 11) should return (4.00 * 8) + (6.00 * 3) or 50.0.

+3
Answers (1)
  1. 25 October, 18:30
    0
    Following is the definition of method pay in Java:

    public static double pay (double sal, int hr)

    {

    double pay;

    if (hr>8)

    {

    pay = sal*8 + (1.5*sal * (hr-8));

    }else

    pay = sal*hr;

    return pay;

    }

    Explanation:

    Sample program to demonstrate above method:

    public class Main

    {

    public static void main (String[] args) {

    System. out. println (pay (5.50, 6));

    System. out. println (pay (4.00, 11));

    }

    public static double pay (double sal, int hr)

    {

    double pay;

    if (hr>8)

    {

    pay = sal*8 + (1.5*sal * (hr-8));

    }else

    pay = sal*hr;

    return pay;

    }

    }

    Output:

    33.0

    50.0
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a method named pay that accepts two parameters: a real number for a TA's salary, and an integer for the number of hours the TA worked ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers