Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examPrep;
- 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 fuel = Double.parseDouble(scanner.nextLine());
- String dayOfWeek = scanner.nextLine();
- double totalSum = (fuel * 2.10) + 100;
- if (dayOfWeek.equals("Saturday")) {
- totalSum = totalSum * 0.90;
- } else if (dayOfWeek.equals("Sunday")){
- totalSum = totalSum * 0.80;
- }
- // switch (dayOfWeek) {
- // case "Saturday":
- // totalSum = totalSum * 0.90;
- // break;
- // case "Sunday":
- // totalSum = totalSum * 0.80;
- // break;
- // }
- double diff = Math.abs(budget - totalSum);
- if (budget >= totalSum) {
- System.out.printf("Safari time! Money left: %.2f lv.", diff);
- } else {
- System.out.printf("Not enough money! Money needed: %.2f lv.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement