Silviyaa

Untitled

Mar 14th, 2021
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P02Safari {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double budget = Double.parseDouble(scanner.nextLine());
  8.         double litersFuel = Double.parseDouble(scanner.nextLine());
  9.         String day = scanner.nextLine(); // "Saturday","Sunday"
  10.  
  11.  
  12.         double priceFuel = litersFuel * 2.10;
  13.         double totalGuide = priceFuel + 100;
  14.         double discount = 0;
  15.  
  16.                 switch (day){
  17.             case "Sunday":
  18.                 discount = totalGuide - 20.0/100;
  19.             case "Saturday":
  20.                  discount = totalGuide * 0.90;
  21.         }
  22.        
  23.         if(budget >= discount ){
  24.             System.out.printf("Safari time! Money left: %.2f lv.",Math.abs(budget - discount));
  25.         }else {
  26.             System.out.printf("Not enough money! Money needed: %.2f lv.",Math.abs(discount - budget));
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment