Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Problem04 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- //• Сумата предвидена за гост изпълнителя - цяло число в интервала [1… 4500]
- //•"The restaurant is full") - броят на хората във всяка група.
- String input = scan.nextLine();
- int target = Integer.parseInt(input); //Integer.parseInt(scan.nextLine());
- int money = 0;
- int totalPeopleCnt = 0;
- String data = scan.nextLine();
- while (!"The restaurant is full".equals(data)) {
- int peopleCnt = Integer.parseInt(data);
- totalPeopleCnt += peopleCnt;
- if (peopleCnt < 5) {
- money = money + (peopleCnt * 100);
- } else {
- money = money + (peopleCnt * 70);
- }
- data = scan.nextLine();
- }
- //• Ако Марто успее да си позволи гост изпълнител:
- //"You have {брой гости} guests and {останалата сума} leva left."
- //• Ако Марто не успее да си позволи гост изпълнител:
- //"You have {брой гости} guests and {приходи} leva income, but no singer."
- if (money >= target) {
- int moneyLeft = money - target;
- System.out.printf("You have %d guests and %d leva left.", totalPeopleCnt, moneyLeft);
- } else {
- System.out.printf("You have %d guests and %d leva income, but no singer.", totalPeopleCnt, money);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement