Judge Fail - Проблем
Здравейте , Judge ми дава грешка на този вход от задача Trade Commission при вход // Sofia 10005 // Правилния изход е 1000.50 , както ми излиза в Intelli , но в Judge вади 1200.60 и го смята за грешка . Това е кода :
import java .util.Scanner ;
public class TradeComission {
public static void main(String[]args) {
Scanner scanner = new Scanner(System.in);
String town = scanner.nextLine();
double sales = Double.parseDouble(scanner.nextLine());
double commission = -1.0;
if (town.equals("Sofia")) {
if (sales >= 0 && sales <= 500) commission = 0.05;
else if (sales > 500 && sales <= 1000) commission = 0.07;
else if (sales > 1000 && sales < 10000) commission = 0.08;
else if (sales > 10000) commission = 0.10;
}
if(town.equals("Varna")) {
if (sales >= 0 && sales <= 500) commission = 0.045;
else if (sales > 500 && sales <= 1000) commission = 0.075;
else if (sales > 1000 && sales < 10000) commission = 0.10;
else if (sales > 10000) commission = 0.13;
}
if(town.equals("Plovdiv")) {
if (sales >= 0 && sales <= 500) commission = 0.055;
else if (sales > 500 && sales <= 1000) commission = 0.08;
else if (sales > 1000 && sales < 10000) commission = 0.12;
else if (sales > 10000) commission = 0.145;
}
if (commission >= 0)
System.out.printf("%.2f" , sales * commission) ;
else
System.out.println("Error");
}
}
Благодаря предварително ,ако някой каже къде е грешката :) .