Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.String;
- public class Transport {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- double km = Double.parseDouble(console.nextLine());
- String onTime = console.nextLine().toLowerCase();
- double taxiDay = 0.70 + ( km * 0.79);
- double taxiNight = 0.70 + ( km * 0.90);
- double bus = km * 0.09;
- double train = km * 0.06;
- if( km > 0 && km <= 20) {
- if(onTime.equals("day")) {
- System.out.printf("%.2f", taxiDay);
- }else if(onTime.equals("night")){
- System.out.printf("%.2f", taxiNight);
- }
- }else if( km > 20 && km <=100){
- if(onTime.equals("day") || onTime.equals("night")) {
- System.out.printf("%.2f", bus);
- }
- }else if( km > 100 ){
- if(onTime.equals("day") || onTime.equals("night")) {
- System.out.printf("%.2f", train);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement