Advertisement
jwrbg

sad

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