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);
- String name = scanner.nextLine();
- double budget = Double.parseDouble(scanner.nextLine());
- int beers = Integer.parseInt(scanner.nextLine()),
- chips = Integer.parseInt(scanner.nextLine());
- double beerPrice = beers * 1.20,
- chipsPrice = chips * beerPrice * 0.45,
- sum = beerPrice + Math.ceil(chipsPrice);
- if (budget < sum) {
- System.out.printf("%s needs %.2f more leva!\n", name, sum - budget);
- } else {
- System.out.printf("%s bought a snack and has %.2f leva left.\n", name, budget - sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement