Advertisement
Spocoman

Sweet Dessert

Sep 10th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double budget = Double.parseDouble(scanner.nextLine());
  7.         int guests = Integer.parseInt(scanner.nextLine());
  8.         double bananaPrice = Double.parseDouble(scanner.nextLine()),
  9.                 eggPrice = Double.parseDouble(scanner.nextLine()),
  10.                 berriesKiloPrice = Double.parseDouble(scanner.nextLine()),
  11.                 neededMoney = Math.ceil((double) guests / 6)
  12.                         * (bananaPrice * 2 + eggPrice * 4 + berriesKiloPrice / 5);
  13.  
  14.         if (budget >= neededMoney) {
  15.             System.out.printf("Ivancho has enough money - it would cost %.2flv.", neededMoney);
  16.         } else {
  17.             System.out.printf("Ivancho will have to withdraw money - he will need %.2flv more.", neededMoney - budget);
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement