Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ZadachiOtIzpita2;
- import java.util.Scanner;
- public class BeerAndChips {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String nameFan = scanner.nextLine();
- double budjet = Double.parseDouble(scanner.nextLine());
- int countBottles = Integer.parseInt(scanner.nextLine());
- int countChips = Integer.parseInt(scanner.nextLine());
- double total = 1.20 * countBottles + Math.ceil((0.45 * 1.20 * countBottles) * countChips);
- if (total <= budjet) {
- System.out.printf(nameFan + " bought a snack and has %.2f leva left.", budjet - total);
- } else
- {
- System.out.printf(nameFan + " needs %.2f more leva!", total - budjet);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement