Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S3_ConditionalStatementsAdvanced;
- 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 fishersCount = Integer.parseInt(scanner.nextLine());
- double shipRent = 0.0;
- if(season.equals("Spring")) {
- shipRent = 3000.0;
- }
- else if (season.equals("Summer") || season.equals("Autumn")) {
- shipRent = 4200.0;
- }
- else if (season.equals("Winter")) {
- shipRent = 2600.0;
- }
- if(fishersCount <= 6) {
- //shipRent = shipRent - (shipRent * 0.10);
- shipRent = shipRent * 0.90;
- } else if (fishersCount >= 7 && fishersCount <= 11) {
- //shipRent = shipRent - (shipRent * 0.15);
- shipRent = shipRent * 0.85;
- } else if (fishersCount >= 12) {
- //shipRent = shipRent - (shipRent * 0.25);
- shipRent = shipRent * 0.75;
- }
- if(fishersCount % 2 == 0 && !(season.equals("Autumn")) ) {
- //shipRent = shipRent - (shipRent * 0.05);
- shipRent = shipRent * 0.95;
- }
- double diff = Math.abs(budget - shipRent);
- if (budget >= shipRent) {
- System.out.printf("Yes! You have %.2f leva left.", diff);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement