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