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