Advertisement
finderabc

task5

Feb 24th, 2020
155
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 task5 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int suma = Integer.parseInt(scanner.nextLine());
  7.         String num = "";
  8.         int money;
  9.         int guest = 0;
  10.         int money1 = 0;
  11.         int money2 =0;
  12.         while (!num.equals("The restaurant is full")){
  13.             int num1 = Integer.parseInt(scanner.nextLine());
  14.             if (num1 < 5){
  15.                money1 = num1 * 100;
  16.                money1 += money1;
  17.             } else {
  18.                 money2 = num1 * 70;
  19.                 money2 += money2;
  20.             }
  21.             guest += num1;
  22.             num = scanner.nextLine();
  23.         }
  24.         money = money1 + money2;
  25.         if (money < suma){
  26.             System.out.printf("You have %d guests and %d leva left.",guest,suma-money);
  27.         } else {
  28.             System.out.printf("You have %d guests and %d leva income, but no singer.",guest,money-suma);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement