Answer:
See explaination for the program code
Explanation:
Meeting.java
------
import java.util.Scanner;
public class Meeting {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
final int ROOM_CAPACITY = 100;
int numPeople, diff;
String name;
System.out.println("****** Meeting Organizer ******");
System.out.print("Enter your name: ");
name = input.nextLine();
System.out.println("Welcome " + name);
do{
System.out.print("\nHow many people would attend the meeting? (type 0 to quit): ");
numPeople = input.nextInt();
if(numPeople < 0)
System.out.println("Invalid input!");
else if(numPeople != 0)
{
if(numPeople > ROOM_CAPACITY)
{
diff = numPeople - ROOM_CAPACITY;
System.out.println("Sorry! The room can only accommodate " + ROOM_CAPACITY +" people. ");
System.out.println(diff + " people have to drop off");
}
else if(numPeople < ROOM_CAPACITY)
{
diff = ROOM_CAPACITY - numPeople;
System.out.println("The meeting can take place. You may still invite " + diff + " people");
}
else
{
System.out.println("The meeting can take place. The room is full");
}
}
}while(numPeople != 0);
System.out.println("Goodbye!"); }
}
output
---
****** Meeting Organizer ******
Enter your name: John
Welcome John
How many people would attend the meeting? (type 0 to quit): 40
The meeting can take place. You may still invite 60 people
How many people would attend the meeting? (type 0 to quit): 120
Sorry! The room can only accommodate 100 people.
20 people have to drop off
How many people would attend the meeting? (type 0 to quit): 100
The meeting can take place. The room is full
How many people would attend the meeting? (type 0 to quit): 0
Goodbye!