Question: I need help with this Java program. Each step of the instructions is associated with specific tests, so you can test your program as you

I need help with this Java program.

Each step of the instructions is associated with specific tests, so you can test your program as you go

along.

Program Requirements

A party planner needs to do calculations for an event, based on the number of guests and the size of

tables. Class files are PartyPlanner.java and Party.java

Test 1:

Within the PartyPlanner class:

? Write the code to read the number of guests and table capacity (i.e. number of people that each

table will hold) from the user as integers.

? After reading the first input, display a "Guest input valid integer" message

? After reading the second input, display a "Table input valid integer" message

Example:

Enter number of guests:

10

Guest input valid integer

Enter capacity of one table:

5

Table input valid integer

Tests 2 through 4:

Within the PartyPlanner class:

? Add an exception handler that includes:

o A try block around the code that reads the user inputs.

? If no exception is thrown after reading the first input, display the same "Guest input

valid integer" message as before

? If no exception is thrown after reading the second input, display the same "Table

input valid integer" message as before

o A catch block to catch the InputMismatchException thrown if the user does not enter an

integer for one of the inputs.

? The catch block should display "Error - did not enter an integer value"

Test 5:

Within the Party class:

? Add a constructor that has parameters for both data fields.

? Add getters for both data fields.

Test 6 :

Within the Party class:

? Add a calcFullTables() method that will divide numGuests by tableCapacity to determine and

return an integer containing how many full tables would be needed for the event

(NOTE: use integer division to ignore any remainder).

Test 7 :

Within the PartyPlanner class:

? Add code to the try block in the main method to:

o Create an object with the user entered values as arguments to the constructor

o Use the object created to call the calcFullTables() method.

o Display the results, using the getter to access numGuests, in the format:

3 full table(s) needed for party of 30 guests

Test 8 (10 pts):

Within the PartyPlanner class:

? Add a second catch block that will catch the ArithmeticException that may be thrown when the

calcFullTables() method is called and the table capacity is 0 during the division.

o The catch block should display "Error - cannot determine number of tables

when table capacity is 0"

Test 9 through 12:

Within the Party class:

? Within the calcFullTables() method, before doing any calculations,

add code to throw an IllegalArgumentException when either data field value is negative.

o The throw should create a new IllegalArgumentException with the message "Error -

cannot compute tables using negative value(s)"

Within the PartyPlanner class:

? Add a third catch block that will catch the IllegalArgumentException that may be thrown when

the calcFullTables() method is called.

o The catch block should display the message from the IllegalArgumentException object

? Warning: Do NOT display a quoted String here

display the message from the IllegalArgumentException object

TEMPLATE TO BE USED:

Party.java template

public class Party {

private int numGuests;

private int tableCapacity;

// Insert your code here

}

PartyPlanner.java template

import java.util.InputMismatchException;

import java.util.Scanner;

public class PartyPlanner {

public static void main(String[] args) {

// Insert your code here

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!