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 singerPrice = Integer.parseInt(scanner.nextLine());
- int totalSum = 0;
- int totalGuestCount = 0;
- String input = scanner.nextLine();
- while (!input.equals("The restaurant is full")){
- int guestCount = Integer.parseInt(input);
- int sum = 0;
- int personPrice = 100;
- if(guestCount >= 5){
- personPrice = 70;
- }
- totalSum += guestCount * personPrice;
- totalGuestCount += guestCount;
- input = scanner.nextLine();
- }
- if (totalSum >= singerPrice){
- System.out.printf("You have %d guests and %d leva left.", totalGuestCount, totalSum - singerPrice);
- }else{
- System.out.printf("You have %d guests and %d leva income, but no singer.",totalGuestCount, totalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement