Question: I'm having trouble with this case problem in java I got most of it down but i'm having trouble with the rest. In Chapter 4,

I'm having trouble with this case problem in java I got most of it down but i'm having trouble with the rest.

In Chapter 4, you modified the EventDemo class to demonstrate two Event objects. Now modify that class again as follows:

Instantiate three Event objects, and prompt the user for values for each object.

Change the method that display Event details to use the new isLargeEvent() method and the new price per guests value. use the display method with all three objects.

Create a method that accepts two Event objects and returns the larger one based on number of guests. (If the Events have the same number of guests, you can return either object.) Call this method three times once with each pair of instantiated Events and display the event number and number of guests for each argument as well as the event number and number of guests for the larger Event.

package eventdemo_ch5;

import java.text.DecimalFormat; import java.util.Scanner; public class EventDemo_CH5 {

public static void main(String[] args) { Scanner inputDevice = new Scanner(System.in); int totalGuests; int totalGuests2; int numberEvent; int numberEvent2; System.out.println("Please enter the event number of your choice. "); numberEvent = inputDevice.nextInt(); System.out.println(); System.out.println("Please enter total number of Guests."); totalGuests = inputDevice.nextInt(); System.out.println(); System.out.println("Please enter next event number of your choice "); numberEvent2 = inputDevice.nextInt(); System.out.println(); System.out.println("Please enter number of Guests of next event. "); totalGuests2 = inputDevice.nextInt(); System.out.println(); Event event1 = new Event(totalGuests, numberEvent); event1.display(totalGuests); Event event2 = new Event(totalGuests2, numberEvent2); event2.display(totalGuests); compareGuests(totalGuests, totalGuests2); isLargeEvent(totalGuests); } public static void isLargeEvent(int totalGuests) { DecimalFormat money = new DecimalFormat("$0.00"); if(totalGuests > 50) { System.out.println("Your total number of Guests will be " + totalGuests + "."); System.out.println("You have one big party! Your price is now $32.00! "); double priceTotal = 32.00; double pricePerGuests = priceTotal * totalGuests; System.out.println("Your total Cost will be. " + money.format(pricePerGuests)); } if(totalGuests <= 50) { System.out.println("Your total number of Guests will be " + totalGuests + "."); System.out.println("Your price will be $35.00 per person. "); double priceTotal = 35.00; double pricePerGuests = priceTotal * totalGuests; System.out.println("Your total Cost will be. " + money.format(pricePerGuests)); } } public static void compareGuests(int totalGuests, int totalGuests2) { if(totalGuests == totalGuests2) System.out.println("Both events have the same number of Guests. "); if(totalGuests <= totalGuests2) System.out.println("The first number of guests you enter. " + totalGuests + "is less than the second guests enter. " + totalGuests2); if(totalGuests >= totalGuests2) System.out.println("The first number of guests you enter. " + totalGuests + "is greater than the second guests enter. " + totalGuests2); } }

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!