"New House" judge problem help
Всичко работи перфектно, като направих всички тестове за решение и дори измислих допълнителни, но judge ми дава 40/100 и не разбирам защо, може ли някой да ми каже ?
Ето го решението ми:
import java.util.Scanner; public class Puppy { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String flowers = scanner.nextLine(); int flowersCount = Integer.parseInt(scanner.nextLine()); int budget = Integer.parseInt(scanner.nextLine()); double Price = 0; if (flowers.equals("Roses") && (flowersCount > 80)) { Price = flowersCount * 5; double total = Price - Price * 0.1; if (total > budget) { double a = total - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - total; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Roses") && (flowersCount < 80)) { Price = flowersCount * 5; if (Price > budget) { double a = Price - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - Price; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Dahlias") && (flowersCount > 90)) { Price = flowersCount * 3.80; double total = Price - Price * 0.15; if (total > budget) { double a = total - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - total; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Dahlias") && (flowersCount < 90)) { Price = flowersCount * 3.80; if (Price > budget) { double a = Price - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - Price; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Tulips") && (flowersCount > 80)) { Price = flowersCount * 2.80; double total = Price - Price * 0.15; if (total > budget) { double a = total - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - total; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Tulips") && (flowersCount < 80)) { Price = flowersCount * 2.80; if (Price > budget) { double a = Price - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - Price; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Narcissus") && (flowersCount < 120)) { Price = flowersCount * 3; double total = Price * 0.15 + Price; if (total > budget) { double a = total - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - total; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Narcissus") && (flowersCount > 120)) { Price = flowersCount * 3; if (Price > budget) { double a = Price - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - Price; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Gladiolus") && (flowersCount < 80)) { Price = flowersCount * 2.5; double total = Price * 0.2 + Price; if (total > budget) { double a = total - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - total; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } else if (flowers.equals("Gladiolus") && (flowersCount > 80)) { Price = flowersCount * 2.5; if (Price > budget) { double a = Price - budget; System.out.printf("Not enough money, you need %.2f leva more.", a); } else { double a = budget - Price; System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersCount, flowers, a); } } } }