Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double guests = Double.parseDouble(scanner.nextLine()),
- budget = Double.parseDouble(scanner.nextLine());
- budget -= Math.ceil(guests / 3) * 4 + guests * 2 * 0.45;
- if (budget < 0) {
- System.out.printf("Lyubo doesn't have enough money.\nHe needs %.2f lv. more.", Math.abs(budget));
- } else {
- System.out.printf("Lyubo bought %d Easter bread and %d eggs.\nHe has %.2f lv. left.", (int) Math.ceil(guests / 3), (int) guests * 2, budget);
- }
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int guests = Integer.parseInt(scanner.nextLine()) * 2;
- double budget = Double.parseDouble(scanner.nextLine())
- - Math.ceil(1.0 * guests / 3) * 4 + guests * 0.45;
- if (budget < 0) {
- System.out.printf("Lyubo doesn't have enough money.\nHe needs %.2f lv. more.", Math.abs(budget));
- } else {
- System.out.printf("Lyubo bought %d Easter bread and %d eggs.\nHe has %.2f lv. left.", (int) Math.ceil(1.0 * guests / 3), guests, budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement