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