Advertisement
Dido09

04.BachelorParty

Nov 1st, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 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 singerPrice = Integer.parseInt(scanner.nextLine());
  8. int totalSum = 0;
  9. int totalGuestCount = 0;
  10. String input = scanner.nextLine();
  11.  
  12. while (!input.equals("The restaurant is full")){
  13. int guestCount = Integer.parseInt(input);
  14. int sum = 0;
  15. int personPrice = 100;
  16.  
  17. if(guestCount >= 5){
  18. personPrice = 70;
  19.  
  20. }
  21.  
  22. totalSum += guestCount * personPrice;
  23. totalGuestCount += guestCount;
  24.  
  25. input = scanner.nextLine();
  26. }
  27. if (totalSum >= singerPrice){
  28. System.out.printf("You have %d guests and %d leva left.", totalGuestCount, totalSum - singerPrice);
  29. }else{
  30. System.out.printf("You have %d guests and %d leva income, but no singer.",totalGuestCount, totalSum);
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement