Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 money = 0;
- while (!command.equals("The restaurant is full")){
- int group = Integer.parseInt(command);
- guests += group;
- if(group < 5){
- money += group * 100;
- }
- else {
- money += group * 70;
- }
- command = scanner.nextLine();
- }
- if(money >= singer){
- System.out.printf("You have %d guests and %d leva left.", guests, money - singer);
- }
- else {
- System.out.printf("You have %d guests and %d leva income, but no singer.",guests, money);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement