Advertisement
finderabc

Bachelor Party (Exam November 2018 )

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