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 arg[]){
- Scanner scanner = new Scanner(System.in);
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int numPeoples = Integer.parseInt(scanner.nextLine());
- double priceBoat = 0;
- double discount =0;
- switch(season) {
- case "Spring":
- priceBoat = 3000;
- break;
- case "Summer":
- case "Autumn":
- priceBoat = 4200;
- break;
- case "Winter":
- priceBoat = 2600;
- break;
- }
- if ( numPeoples <= 6) {
- priceBoat *= 0.9;
- }
- else if ( numPeoples >= 7 && numPeoples <=11 ) {
- priceBoat *= 0.85;
- }
- else if (numPeoples >= 12) {
- priceBoat *= 0.75;
- }
- if (numPeoples % 2 == 0 && !"Autumn".equals(season)) {
- priceBoat *= 0.95;
- }
- if ( budget >= priceBoat ) {
- double moneyRest = budget - priceBoat;
- System.out.printf("Yes! You have %.2f leva left.", moneyRest);
- }
- else {
- double moneyNeeded = priceBoat - budget;
- System.out.printf("Not enough money! You need %.2f leva.", moneyNeeded);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement