04. Fishing Boat
Здравейте! На тази задачка Judge ми дава 46/100. Ако може да ми кажете къде греша. Благодаря!
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":
priceBoat = 4200;
break;
case "Autumn":
priceBoat = 4200;
break;
case "Winter":
priceBoat = 2600;
break;
}
if ( numPeoples <= 6) {
discount = priceBoat * 0.1;
}
else if ( numPeoples >= 7 && numPeoples <=11 ) {
discount = priceBoat * 0.15;
}
else if (numPeoples >= 12) {
discount = priceBoat * 0.25;
}
double discount2 = 0;
if (numPeoples % 2 == 0 && "Autumn".equals(season)) {
discount2 = 0.5 * priceBoat;
}
else {
discount2 = 0;
}
double discountTotal = discount + discount2;
double priceTotal = priceBoat - discountTotal;
if ( budget > priceTotal ) {
double moneyRest = budget - priceTotal;
System.out.printf("Yes! You have %.2f leva left.", moneyRest);
}
else {
double moneyNeeded = priceTotal - budget;
System.out.printf("Not enough money! You need %.2f leva.", moneyNeeded);
}
}
Благодаря!