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