Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FishingBoat {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int fishermenCount = Integer.parseInt(scanner.nextLine());
- double shipCost = 0;
- double finalCost = 0;
- switch (season) {
- case "Spring":
- if (fishermenCount <= 6) {
- shipCost = 3000 * 0.90;
- }
- else if (fishermenCount >= 7 && fishermenCount <= 11) {
- shipCost = 3000 * 0.85;
- }
- else if (fishermenCount >= 12) {
- shipCost = 3000 * 0.75;
- }
- break;
- case "Summer":
- case "Autumn":
- if (fishermenCount <= 6) {
- shipCost = 4200 * 0.90;
- }
- else if (fishermenCount >= 7 && fishermenCount <= 11) {
- shipCost = 4200 * 0.85;
- }
- else if (fishermenCount >= 12) {
- shipCost = 4200 * 0.75;
- }
- break;
- case "Winter":
- if (fishermenCount <= 6) {
- shipCost = 2600 * 0.90;
- }
- else if (fishermenCount >= 7 && fishermenCount <= 11) {
- shipCost = 2600 * 0.85;
- }
- else if (fishermenCount >= 12) {
- shipCost = 2600 * 0.75;
- }
- break;
- }
- if (!season.equals("Autumn")) {
- if (fishermenCount % 2 == 0) {
- finalCost = shipCost * 0.95;
- }
- else {
- finalCost = shipCost;
- }
- }
- else if (season.equals("Autumn")) {
- finalCost = shipCost;
- }
- if (budget >= finalCost) {
- System.out.printf("Yes! You have %.2f leva left.", budget - finalCost);
- }
- else {
- System.out.printf("Not enough money! You need %.2f leva.", finalCost - budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement