Advertisement
Ivakis

Transport Price

Aug 12th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class p02_TransportPrice {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. double km = Double.parseDouble(scanner.nextLine());
  9. String daynight = scanner.nextLine().toLowerCase();
  10. DecimalFormat format = new DecimalFormat("#.##");
  11.  
  12. if (km <20 && daynight.equals("day")){
  13. double price = 0.70 + 0.79*km;
  14. System.out.printf(format.format(price));
  15.  
  16. } else if (km<20 && daynight.equals("night")){
  17. double price = 0.70 + 0.90*km;
  18. System.out.printf(format.format(price));
  19.  
  20. }if (km>=20 && km<100){
  21. double price = km*0.09;
  22. System.out.printf(format.format(price));
  23.  
  24. }else if (km>=100){
  25. double price = km*0.06;
  26. System.out.printf(format.format(price));
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement