Advertisement
IvaAnd

BachelorsParty

Mar 22nd, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import org.w3c.dom.ls.LSOutput;
  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 singer = Integer.parseInt(scanner.nextLine());
  10. String command = scanner.nextLine();
  11. int guests = 0;
  12. int countGuests = 0;
  13. int expenceCount = 0;
  14. int sumExpences = 0;
  15.  
  16. while (!command.equals("The restaurant is full")) {
  17. guests = Integer.parseInt(command);
  18. countGuests = countGuests + guests;
  19.  
  20. if (guests < 5) {
  21. expenceCount = guests * 100;
  22.  
  23. } else if (guests >= 5) {
  24. expenceCount = guests * 70;
  25. }
  26. sumExpences = sumExpences + expenceCount;
  27.  
  28. command = scanner.nextLine();
  29. }
  30. if (sumExpences>=singer) {
  31. int left = sumExpences - singer;
  32. System.out.printf("You have %d guests and %d leva left.", countGuests, left);
  33. } else {
  34.  
  35. System.out.printf("You have %d guests and %d leva income, but no singer.",countGuests, sumExpences);
  36. }
  37. }
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement