Helena12

Bachelor Party

Dec 12th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ExamNovember04BachelorParty {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int sumaGostIzpalnitel = Integer.parseInt(scanner.nextLine());
  8.         double kuvert = 0;
  9.         double prihod = 0;
  10.         int guestsCount = 0;
  11.         double remainingSum = 0;
  12.  
  13.         String peopleNumberInGroup = scanner.nextLine();
  14.  
  15.         while (!peopleNumberInGroup.equalsIgnoreCase("The restaurant is full")) {
  16.             int peopleNumber = Integer.parseInt(peopleNumberInGroup);
  17.  
  18.             if (peopleNumber < 5) {
  19.                 kuvert = 100;
  20.                 prihod += peopleNumber * kuvert;
  21.                 guestsCount += peopleNumber;
  22.             } else {
  23.                 kuvert = 70;
  24.                 prihod += peopleNumber * kuvert;
  25.                 guestsCount += peopleNumber;
  26.             }
  27.  
  28.                 peopleNumberInGroup = scanner.nextLine();
  29.  
  30.             if (peopleNumberInGroup.equalsIgnoreCase("The restaurant is full")) {
  31.                 break;
  32.             }
  33.         }
  34.             remainingSum = Math.round(prihod - sumaGostIzpalnitel);
  35.  
  36.         if (prihod >= sumaGostIzpalnitel) {
  37.             System.out.printf("You have %d guests and %.0f leva left.", guestsCount, remainingSum);
  38.         } else {
  39.             System.out.printf("You have %d guests and %.0f leva income, but no singer.",
  40.                     guestsCount, prihod);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment