Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

As indicated at http: //wwv.flymemphis.com/parking. Memphis International Airpor

ID: 3855560 • Letter: A

Question

As indicated at http: //wwv.flymemphis.com/parking. Memphis International Airport uses the following pricing schedule for their short-term parking fees: Write a method that takes a parameter for the number of minutes parked (you can assume it's a whole number) and returns the appropriate short-term parking charge, in dollars. Assume that the airport will always round UP to the next half-hour - for example parking exactly 60 minutes would cost $2 but 61 minutes would make it $3. After all, they want to make as much money as possible!. If the method is called with a zero or negative argument, make it return zero. If the method is called with an argument exceeding 24 hours, make it return the 24-hour maximum listed m the table. You do not need to write a separate main method for this problem, but be sure to thoroughly test your pricing method by calling it from BlueJ!

Explanation / Answer

public static int Parking_fee (int t)

{

if(t<=0)

{

return 0;

}

else

{

  int fee,temp,ad;

if (t <= 30)

{

fee=0;

}

else if (t >= 24)

{

                                    fee=24;

}

else

{

                        if (t>30 && t<=60)

{

fee=2;

}

else

{

                       temp=(t-60) / 30;

                     ad=(t-60) % 30;

                     if (ad>0)

                     {

                               fee=2+temp+1;

                      }

else

{

                        fee=2+temp;

}

                                    }

}

return fee;

}

}