Advertisement
_Maximilian_

Цена на транспорт

Jan 21st, 2020 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class homework {
  4.  
  5.   public static void main(String[] args) {
  6.  
  7.     Scanner s = new Scanner(System.in);
  8.  
  9.     int km = Integer.parseInt(s.nextLine());
  10.  
  11.     double taxi =0;
  12.  
  13.     double price =0;
  14.  
  15.     String time=s.nextLine();
  16.  
  17.     if(time.equals("day")){
  18.  
  19.     taxi=0.79;
  20.  
  21.     }else if(time.equals("night")){
  22.  
  23.     taxi = 0.9;
  24.  
  25.   }
  26.  
  27.   if(km<20){
  28.  
  29. price=(taxi*km)+0.7;
  30.  
  31. System.out.println(price);
  32.  
  33.   }
  34.  
  35.   if(km>20 && km<100){
  36.  
  37.     price=km*0.09;
  38.  
  39.    System.out.println(price);
  40.  
  41.   }
  42.  
  43. if(km>100){
  44.  
  45.     price=km*0.06;
  46.  
  47.    System.out.println(price);
  48.  
  49.   }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement