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 budget = Double.parseDouble(scanner.nextLine());
- int guests = Integer.parseInt(scanner.nextLine());
- double bananaPrice = Double.parseDouble(scanner.nextLine()),
- eggPrice = Double.parseDouble(scanner.nextLine()),
- berriesKiloPrice = Double.parseDouble(scanner.nextLine()),
- neededMoney = Math.ceil((double) guests / 6)
- * (bananaPrice * 2 + eggPrice * 4 + berriesKiloPrice / 5);
- if (budget >= neededMoney) {
- System.out.printf("Ivancho has enough money - it would cost %.2flv.", neededMoney);
- } else {
- System.out.printf("Ivancho will have to withdraw money - he will need %.2flv more.", neededMoney - budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement