Ask Question
8 October, 03:14

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.

+5
Answers (1)
  1. 8 October, 05:05
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers