Проблем със задача Hungry Garfield(от изпита от 21.02.2016г) на Java
Здравейте, нещо не ми се получава задачата Hungry Garfield, не мога да си открия грешките. На Judge ми дава немалко точки, но все пак не е 100/100. Някой може ли да помогне?
Кода ми е следния:
import java.util.Scanner; public class hungryGarfield210216 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double money = Double.parseDouble(scan.nextLine()); double rate = Double.parseDouble(scan.nextLine()); double price1 = Double.parseDouble(scan.nextLine()); double price2 = Double.parseDouble(scan.nextLine()); double price3 = Double.parseDouble(scan.nextLine()); double count1 = Double.parseDouble(scan.nextLine()); double count2 = Double.parseDouble(scan.nextLine()); double count3 = Double.parseDouble(scan.nextLine()); double moneyNeeded = price1/rate * count1 + price2/rate * count2 + price3/rate * count3; if(money >= moneyNeeded){ System.out.printf("Garfield is well fed, John is awesome. Money left: $%.2f.",money - moneyNeeded); }else{ System.out.printf("Garfield is hungry. John is a badass. Money needed: $%.2f.",Math.abs(moneyNeeded - money)); } } }