dwarf presents
здравейте колеги,
може ли някой да ми каже, къде се чупи този код?
import java.util.Scanner;
public class Problem4 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = Integer.parseInt(scanner.nextLine());
int moneyHave = Integer.parseInt(scanner.nextLine());
double price = 0.0;
if (n!=0) {
for (int i = 0; i < n; i++) {
String input = scanner.nextLine();
if (input.equals("sand clock")) {
price += 2.20;
} else if (input.equals("magnet")) {
price += 1.50;
} else if (input.equals("cup")) {
price += 5.00;
} else if (input.equals("t-shirt")) {
price += 10.00;
}
}
double total = Math.abs(moneyHave - price);
if (price < moneyHave) {
System.out.printf("Santa Claus has %.2f more leva left!", total);
} else {
System.out.printf("Santa Claus will need %.2f more leva.", total);
}
}
}
}
Съедечно благодаря!