Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EP06FishBoat {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int fishers = Integer.parseInt(scanner.nextLine());
- double price = 0;
- if (season.equalsIgnoreCase("spring")) {
- price = 3000;
- if (fishers % 2 == 0) {
- price *= 0.95;
- }
- }
- else if (season.equalsIgnoreCase("summer") || season.equalsIgnoreCase("autumn")) {
- price = 4200;
- if (fishers % 2 == 0 && !season.equalsIgnoreCase("autumn")) {
- price *= 0.95;
- }
- }
- else if (season.equalsIgnoreCase("winter")) {
- price = 2600;
- if (fishers % 2 == 0) {
- price *= 0.95;
- }
- }
- if (fishers <= 6) {
- price *= 0.90;
- } else if (fishers <= 11) {
- price *= 0.85;
- } else {
- price *= 0.75;
- }
- if (budget >= price) {
- System.out.printf("Yes! You have %.2f leva left.", budget - price);
- }
- else {
- System.out.printf("Not enough money! You need %.2f leva.", price - budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment