Advertisement
galinyotsev123

ProgBasicsExam3and4November2018-E04bachelorParty

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