Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Class called Event using the UML diagram below. Event - String type - double price - int sales + Event (String, cost, double):

image text in transcribed
image text in transcribed
image text in transcribed
Create a Class called Event using the UML diagram below. Event - String type - double price - int sales + Event (String, cost, double): + getType(): String + getPrice(): double + getSales(): int + setType(String): void + setPrice (double): void + setSales(int): void + moreSales (Event): boolean + toString (): String - The constructor sets the Event's type, the price of the event and - The constructor sets the Event's type, the price of the event and number of sold tickets (sales). - The method moreSales returns true if this Event object's sales are the higher than an another Event object's sales. - The toString method returns a String in the following format (for example, if the event type was MooseheadsHockeyGame and the price was $15, and tickets sold (sales) was 500 ) : I Event: MooseHeadsHockeyGame Price: $15.00 Sales: 500 HINT: to print out a formatted price (with 2 decimal places) in the to String method you can use the DecimalFormat class. Make sure to import java.text.DecimalFormat in the Event class. Then declare a DecimalFormat object in the toString method (e.g.. DecimalFormat df = new Decimalformat("\#.00"): ), then when you return the price of the event use the DecimalFormat method format (e.g., df.format(price)). Then create EventDemo class to test the Event class. Use a Scanner object to read in the event type and price for two Events objects. Then read in an integer that represents the number of sales to add to the first event (add to the current sales) and then read another integer that represents the number of sales to add to the current number of sates for the second event. Print both Event objects using the toString method. Then print if the first Event object has more sales than the second Event object

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

2. Explain how the role of training is changing.

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago