Suppose your cell phone carrier charges you a monthly fee of $30.00 for up to 300 minutes and $0.45 for each additional minute after the first 300. Assuming you used your phone for x minutes with x > 300, the total monthly fee would be?

If you used your phone for <= 300 minutes then the charge is $30.00 Assume the user enters a positive value for the number of minutes

Respuesta :

Answer:

30.00 + x * .45 where x is the number of minutes

in code it would be:

import java.util.Scanner;

public class monthlyFee{

   final double MONTHLY_FEE = 30.00;

   final double ADDITIONAL_MINUTE_FEE = 0.45;

   double additionalMinute = 0;

   public monthlyFee(double minutes){

   additionalMinute = minutes;

   }

   public double calculate(){

       if(additionalMinute > 0){

       double TotalFee = MONTHLY_FEE + additionalMinute * ADDITIONAL_MINUTE_FEE;

       return TotalFee;

       }

       else

       return MONTHLY_FEE;

   }

   public static void main(String...args){

   Scanner input = new Scanner(System.in);

   System.out.println("Enter minutes: ");

   double minutes = input.nextDouble();

   monthlyFee obj1 = new monthlyFee(minutes);

   System.out.printf("$" + "%.2f", obj1.calculate());

   }

}

Explanation:

so whatever x is just multiple it by 0.45 to get the total for just the fee.