Answer:
public static double calculate_fee(int lengthofRide, String membership){
double fee = 0.0;
if(membership.equalsIgnoreCase("daily")){
fee = 1.50 +(lengthofRide*20);
}
else if (membership.equalsIgnoreCase("annually")){
fee = 1.0+(lengthofRide*15);
}
return fee;
}
Explanation:
The solution is implemented in Java. The complete code prompting the user to enter ride duration and membership type is given below:
import java.util.Scanner;
public class num4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter your membership \"daily\" of \"annually\"");
String membership = in.nextLine();
System.out.println("Enter your ride duration in minutes");
int rideTime = in.nextInt();
//calling the method calculate_fee
System.out.println("Your total fee based on your membership is "+calculate_fee(rideTime,membership));
}
public static double calculate_fee(int lengthofRide, String membership){
double fee = 0.0;
if(membership.equalsIgnoreCase("daily")){
fee = 1.50 +(lengthofRide*20);
}
else if (membership.equalsIgnoreCase("annually")){
fee = 1.0+(lengthofRide*15);
}
return fee;
}
}