## Проблем със задача 03. New House от Conditional Statements Advanced - Excercise

Задачата отговаря на примерните входове от документа, обаче на Judge вади 50/100? И със switch - case се опитах и пак не става. Благодаря предварително !

import java.util.Scanner;

public class NewHome {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String flower = scanner.nextLine();
double flowers = Double.parseDouble(scanner.nextLine());
double budget = Double.parseDouble(scanner.nextLine());
double rose = 5.00;
double dahlia = 3.80;
double tulip = 2.8;
double narcissus = 3;
double sum = 0;
double leftover = 0;
double need = 0;

if (flower.equals("Roses")) {
sum = flowers * rose;
if (flowers > 80) {
sum = flowers * rose - (flowers * rose * 0.1);
}
} else if (flower.equals("Dahlias")) {
sum = flowers * dahlia;
if (flowers > 90) {
sum = flowers * dahlia - (flowers * dahlia * 0.15);
}
} else if (flower.equals("Tulips")) {
sum = flowers * tulip;
if (flowers > 80) {
sum = flowers * tulip - (flowers * tulip * 0.15);
}
} else if (flower.equals("Narcissus")) {
sum = flowers * narcissus;
if (flowers < 120) {
sum = flowers * narcissus + (flowers * narcissus * 0.15);
}
if (flowers < 80) {
}
}
if (sum > budget) {
need = budget - sum;
System.out.printf("Not enough money, you need %.2f leva more.", Math.abs(need));
} else if (sum < budget) {
leftover = budget - sum;
System.out.printf("Hey, you have a great garden with %.0f %s and %.2f leva left.", flowers, flower, leftover);

}
}
}

Тагове:
0
MANEKENA 118 Точки

Ето ти моето решение : https://pastebin.com/Bba0auqE

0