Advertisement
veronikaaa86

02. Safari

Feb 18th, 2023 (edited)
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P02Safari {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double budget = Double.parseDouble(scanner.nextLine());
  10.         double fuel = Double.parseDouble(scanner.nextLine());
  11.         String dayOfWeek = scanner.nextLine();
  12.  
  13.         double totalSum = (fuel * 2.10) + 100;
  14.  
  15.         if (dayOfWeek.equals("Saturday")) {
  16.             totalSum = totalSum * 0.90;
  17.         } else if (dayOfWeek.equals("Sunday")){
  18.             totalSum = totalSum * 0.80;
  19.         }
  20.  
  21. //        switch (dayOfWeek) {
  22. //            case "Saturday":
  23. //                totalSum = totalSum * 0.90;
  24. //                break;
  25. //            case "Sunday":
  26. //                totalSum = totalSum * 0.80;
  27. //                break;
  28. //        }
  29.  
  30.         double diff = Math.abs(budget - totalSum);
  31.         if (budget >= totalSum) {
  32.             System.out.printf("Safari time! Money left: %.2f lv.", diff);
  33.         } else {
  34.             System.out.printf("Not enough money! Money needed: %.2f lv.", diff);
  35.         }
  36.  
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement