Programming Basics Java Exam
На задача 2 Wedding Party https://softuni.bg/downloads/svn/programming-basics/2018-09/Exam/2.%20Wedding%20Party.pdf, как да направя така, че ако бюджета не е достатъчен да ми даде грешка. Ето моя код до сега
package EXAM; import java.util.Scanner; public class WeddingParty { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double guests = Double.parseDouble(scanner.nextLine()); double budget = Double.parseDouble(scanner.nextLine()); double remainingMoney = Math.abs(20 * guests - budget); double fireWorksPrice = 0.4 * remainingMoney; double donationMoney = remainingMoney - fireWorksPrice; System.out.printf("Yes! %.0f lv are for fireworks and %.0f lv are for donation", fireWorksPrice, donationMoney); } }