New house - Java
Здравейте!
Имам следният проблем: в InteliJ кода си работи нормалмо, а в Judge ми дава грешки.
Кодът :
import java.util.Scanner;
public class Tutorial {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String flowersType = scanner.nextLine();
int flowersBought = Integer.parseInt(scanner.nextLine());
int budget = Integer.parseInt(scanner.nextLine());
double totalSum = 0;
int flowersBought = Integer.parseInt(scanner.nextLine());
int budget = Integer.parseInt(scanner.nextLine());
double totalSum = 0;
switch (flowersType) {
case "Roses":
totalSum = flowersBought * 5;
if (flowersBought > 80){
totalSum = totalSum * 0.9;
}break;
case "Dahlias":
totalSum = flowersBought * 3.5;
if (flowersBought > 90){
totalSum = totalSum * 0.85;
}break;
case "Tulips":
totalSum = flowersBought * 2.8;
if (flowersBought > 80){
totalSum = totalSum * 0.85;
}break;
case "Narcissus":
totalSum = flowersBought * 3;
if (flowersBought < 120){
totalSum = totalSum * 1.15;
}break;
case "Gladious":
totalSum = flowersBought * 2.5;
if (flowersBought < 80){
totalSum = totalSum * 1.2;
}break;
}
if (budget > totalSum) {
System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersBought, flowersType, (budget - totalSum));
}else {
System.out.printf("Not enough money, you need %.2f leva more.", totalSum - budget);
}
}
}
case "Roses":
totalSum = flowersBought * 5;
if (flowersBought > 80){
totalSum = totalSum * 0.9;
}break;
case "Dahlias":
totalSum = flowersBought * 3.5;
if (flowersBought > 90){
totalSum = totalSum * 0.85;
}break;
case "Tulips":
totalSum = flowersBought * 2.8;
if (flowersBought > 80){
totalSum = totalSum * 0.85;
}break;
case "Narcissus":
totalSum = flowersBought * 3;
if (flowersBought < 120){
totalSum = totalSum * 1.15;
}break;
case "Gladious":
totalSum = flowersBought * 2.5;
if (flowersBought < 80){
totalSum = totalSum * 1.2;
}break;
}
if (budget > totalSum) {
System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersBought, flowersType, (budget - totalSum));
}else {
System.out.printf("Not enough money, you need %.2f leva more.", totalSum - budget);
}
}
}
В Judge на Zero test #5 със следните данни :
Gladiolus
64
160
ми излиза:
Expected output:
1
Not enough money, you need 32.00 leva more.
2
Your output:
1
Hey, you have a great garden with 64 Gladiolus and 160.00 leva left.
2
А в InteliJ си върви нормално и излиза Not enough money.....