Advertisement
SUni2020

05.BachelorParty

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