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 sesson = scanner.nextLine();
- int numFishman = Integer.parseInt(scanner.nextLine());
- double price = 0.0;
- //"Spring", "Summer", "Autumn", "Winter"
- switch (sesson) {
- case "Spring":
- price = 3000;
- if (numFishman<=6){
- price *= 0.90;
- }else if(numFishman<=11){
- price *=0.85;
- }else{
- price *= 0.75;
- }
- if (numFishman%2 == 0){
- price *= 0.95;
- }
- break;
- case "Summer":
- price = 4200;
- if (numFishman<=6){
- price *= 0.90;
- }else if(numFishman<=11){
- price *=0.85;
- }else {
- price *= 0.75;
- if (numFishman%2 == 0){
- price *= 0.95;
- }
- }
- break;
- case "Autumn":
- price = 4200;
- if (numFishman<=6){
- price *= 0.90;
- }else if(numFishman<=11){
- price *=0.85;
- }else{
- price *= 0.75;
- }
- break;
- case "Winter":
- price = 2600;
- if (numFishman<=6){
- price *= 0.90;
- }else if(numFishman<=11){
- price *=0.85;
- }else{
- price *= 0.75;
- if (numFishman%2 == 0){
- price *= 0.95;
- }
- }
- break;
- }
- 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
Advertisement