Advertisement
HristoGeorgiev

Untitled

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