Toy Shop JAVA
Линк към условието: https://softuni.bg/trainings/resources/officedocument/35389/lab-problem-descriptions-programming-basics-with-java-october-2018/2155 Здравейте, това е решението на задачата. В judge ми дава 60/100 точки, но не мога да си намеря грешката. import java.util.Scanner; import java.util.ServiceConfigurationError; public class Demo { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double trip = Double.parseDouble(scanner.nextLine()); int puzzle = Integer.parseInt(scanner.nextLine()); int doll = Integer.parseInt(scanner.nextLine()); int bears = Integer.parseInt(scanner.nextLine()); int minions = Integer.parseInt(scanner.nextLine()); int truck = Integer.parseInt(scanner.nextLine()); double puzzlePrice = 2.60; int dollPrice = 3; double bearsPrice = 4.10; double minionsPrice = 8.20; int truckPrice = 2; double sum = puzzle * puzzlePrice + doll * dollPrice + bears * bearsPrice + minions * minionsPrice + truck * truckPrice; // сума int numberOfToys = puzzle + doll + bears + minions + truck; if (numberOfToys >= 50) { double discount = sum * 0.25; double sumMinusDiscount = sum - discount; // крайна цена double rent = 0.10 * sumMinusDiscount; double income = sumMinusDiscount - rent; if (income >= trip) { double spare = income - trip; System.out.printf("Yes! %.2f lv left.", spare); } } if (numberOfToys < 50) { double rentTwo = 0.10 * sum; double incomeTwo = sum - rentTwo; if (incomeTwo < trip) { double notEnough = trip - incomeTwo; System.out.printf("Not enough money! %.2f lv needed.", notEnough); } } } }
Като я стартирам програмата и въведа тези стойности 320 ; 8 ; 2 ; 5 ; 5 ; 1 ми изпечатва Not enough money! 320,00 lv needed.
Дори и да въведа произволни стойности винаги ми печати цената на екскурзията.
Това е твоят код:
това е моят :