import java.util.ArrayList;
public class TransitCalculator{
int days;
int rides;
public TransitCalculator(int noOfDays, int noOfRides){
days = noOfDays;
rides = noOfRides;
}
double payPerRide = 2.75;
double unlimitedRide_7 = 33;
double unlimitedRide_30 = 127;
// Returns Price Per Ride using 7-day Unlimited rides option
public double unlimited7Price(){
int noOfWeeks = (days / 7) + 1;
if(days == 7) noOfWeeks = 1;
double pricePerRide = unlimitedRide_7*noOfWeeks/rides;
return pricePerRide;
}
// Returns Price Per Ride using 30-day Unlimited rides option
public double unlimited30Price(){
int noOfMonths = (days / 30) + 1;
if(days == 30) noOfMonths = 1;
double pricePerRide = unlimitedRide_30*noOfMonths/rides;
return pricePerRide;
}
ArrayList<Double> ridePrice = new ArrayList<Double>();
// returns an arraylist of prices per ride for all three options
public ArrayList<Double> getRidePrices(){
ridePrice.add(payPerRide);
this.unlimited7Price();
ridePrice.add(unlimited7Price());
this.unlimited30Price();
ridePrice.add(unlimited30Price());
return ridePrice;
}
//return the best price option for you
public String getBestFare(){
double lowestPrice = 2.75;
for(int i = 0;i<ridePrice.size();i++){
if(ridePrice.get(i)<lowestPrice){
lowestPrice =ridePrice.get(i);
}
}
return "you should go for "
}
public static void main(String[] args){
TransitCalculator calculate = new TransitCalculator(19,50);
System.out.println(calculate.getRidePrices());
System.out.println(calculate.getBestFare());
}
}
how do I return the statement with no of days and best fare price in getBestFare() method.
someone pls tell