Advertisement
finderabc

Problem05

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