Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FourthTask {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int singer = Integer.parseInt(scanner.nextLine());
- int totalMoneyForGroups = 0;
- int counter = 0;
- while (true) {
- String currentCommand = scanner.nextLine();
- if(currentCommand.equals("The restaurant is full"))
- break;
- int peopleCount = Integer.parseInt(currentCommand);
- if (peopleCount < 5) {
- totalMoneyForGroups += peopleCount * 100;
- } else {
- totalMoneyForGroups += peopleCount * 70;
- }
- counter += peopleCount;
- }
- if (singer < totalMoneyForGroups) {
- System.out.printf("You have %d guests and %d leva left.", counter, totalMoneyForGroups - singer);
- } else {
- System.out.printf("You have %d guests and %d leva income, but no singer.", counter, totalMoneyForGroups);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement