Advertisement
Guest User

BachelorParty

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