Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P02Safari {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- double litersFuel = Double.parseDouble(scanner.nextLine());
- String day = scanner.nextLine(); // "Saturday","Sunday"
- double priceFuel = litersFuel * 2.10;
- double totalGuide = priceFuel + 100;
- double discount = 0;
- switch (day){
- case "Sunday":
- discount = totalGuide - 20.0/100;
- case "Saturday":
- discount = totalGuide * 0.90;
- }
- if(budget >= discount ){
- System.out.printf("Safari time! Money left: %.2f lv.",Math.abs(budget - discount));
- }else {
- System.out.printf("Not enough money! Money needed: %.2f lv.",Math.abs(discount - budget));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment