Advertisement
Guest User

BachelorParty

a guest
Feb 23rd, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 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.        
  9.         int guests = 0;
  10.         int money = 0;
  11.        
  12.         String command = scanner.nextLine();
  13.  
  14.         while (!command.equals("The restaurant is full")){
  15.             int group = Integer.parseInt(command);
  16.             guests += group;
  17.            
  18.             if(group < 5){
  19.                 money += group * 100;
  20.             }
  21.             else {
  22.                 money += group * 70;
  23.             }
  24.  
  25.             command = scanner.nextLine();
  26.  
  27.         }
  28.         if(money >= singer){
  29.             System.out.printf("You have %d guests and %d leva left.", guests, money - singer);
  30.         }
  31.         else {
  32.             System.out.printf("You have %d guests and %d leva income, but no singer.",guests, money);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement