Advertisement
Ligh7_of_H3av3n

02.BeerAndChips

Oct 21st, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. package ZadachiOtIzpita2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class BeerAndChips {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.        String nameFan = scanner.nextLine();
  10.         double budjet = Double.parseDouble(scanner.nextLine());
  11.         int countBottles = Integer.parseInt(scanner.nextLine());
  12.         int countChips = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double total = 1.20 * countBottles + Math.ceil((0.45 * 1.20 * countBottles) * countChips);
  15.  
  16.         if (total <= budjet) {
  17.             System.out.printf(nameFan + " bought a snack and has %.2f leva left.", budjet - total);
  18.         } else
  19.         {
  20.             System.out.printf(nameFan + " needs %.2f more leva!", total - budjet);
  21.         }
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement