Created
April 3, 2014 04:10
-
-
Save talobin/9948143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloWorld{ | |
public static void main(String []args){ | |
System.out.println("Fee for 23 minutes"); | |
System.out.println(fee(23)); | |
System.out.println("Fee for 60 minutes"); | |
System.out.println(fee(60)); | |
System.out.println("Fee for 61 minutes"); | |
System.out.println(fee(61)); | |
System.out.println("Fee for 93 minutes"); | |
System.out.println(fee(93)); | |
System.out.println("Fee for 163 minutes"); | |
System.out.println(fee(163)); | |
System.out.println("Fee for 263 minutes"); | |
System.out.println(fee(263)); | |
System.out.println("Fee for 420 minutes"); | |
System.out.println(fee(420)); | |
System.out.println("Fee for 421 minutes"); | |
System.out.println(fee(421)); | |
System.out.println("Fee for 1440 minutes"); | |
System.out.println(fee(1440)); | |
System.out.println("Fee for 4000 minutes"); | |
System.out.println(fee(4000)); | |
} | |
public static double fee(int time){ | |
if (time <=0) | |
return 0; | |
else{ | |
double[] fee_array = {0,2,1,14,1,21};//First 30 min,31 to 60, each addition 30, up to 7 hrs, each hr after 7, max 24 | |
if (time >= 24*60)// for time exceeds 24 | |
return fee_array[5]; | |
else{ | |
if (time <= 30) // for first 30 min | |
return fee_array[0]; | |
else{ | |
if (time <= 60) //for 31 to 60 | |
return fee_array[1]; | |
else{ | |
if (time < 7*60){ //for btw 1hr and 7hr | |
return fee_array[1] + (time-60+30)/30*fee_array[2]; | |
} | |
else{//for greater than 7hr | |
return fee_array[3] + ((time -60*7+59)/60)*fee_array[4]; | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment