1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vlada-n [284]
3 years ago
5

A. Carly’s Catering provides meals for parties and special events. In Chapter 3, you created an Event class for the company. The

Event class contains two public final static fields that hold the price per guest ($35) and the cutoff value for a large event (50 guests), and three private fields that hold an event number, number of guests for the event, and the price. It also contains two public set methods and three public get methods.
Now, modify the Event class to contain two overloaded constructors

∎ One constructor accepts an event number and number of guests as parameters. Pass these values to the setEventNumber() and setGuests() methods, respectively. The setGuests() method will automatically calculate the event price.

∎ The other constructor is a default constructor that passes "A000" and 0 to the two-parameter constructor.

Save the file as Event.java

b. In Chapter 3, you also created an EventDemo class to demonstrate using two Event objects. Now, modify that class to instantiate two Event objects, and include the following new methods in the class:

∎ Instantiate one object to retain the constructor default values

∎ Accept user data for the event number and guests fields, and use this data set to instantiate the second object. Display all the details for both objects.

Save the file as EventDemo.java.
Computers and Technology
1 answer:
Tpy6a [65]3 years ago
5 0

Answer:

import java.util.Scanner;

public class Event {

  public final static double LOWER = 32.00;

  public final static double HIGHER = 35.00;

  public final static int CUTOFF_VALUE = 50;

  public boolean largeEvent;

  private String eventNum;

  private int totalGuests;

  private double price;

  private double pricePerGuest;

  public Event(String event, int guests) {

      eventNum = event;

      totalGuests = guests;

  }

  public Event() {

      this("A000", 0);

  }

  private Scanner input = new Scanner(System.in);

  public void setEventNumber() {

      System.out.print("Enter the event number? ");

      eventNum = input.nextLine();

  }

  public void settotalGuests() {

      System.out.print("Enter total guests that are attending the event? ");

      totalGuests = input.nextInt();

      if (isLargeEvent())

          pricePerGuest = LOWER;

      else

          pricePerGuest = HIGHER;

      price = totalGuests * pricePerGuest;

      largeEvent = (totalGuests >= CUTOFF_VALUE);

      System.out.println("");

  }

  public boolean isLargeEvent() {

      if (this.gettotalGuests() > 50)

          return true;

      else

          return false;

  }

  public String getEventNumber() {

      return eventNum;

  }

  public int gettotalGuests() {

      return totalGuests;

  }

  public double getPrice() {

      return price;

  }

}

public class EventDemo {

  public static void main(String[] args) {

      Event event1 = new Event();

      Event event2 = new Event();

      Event event3 = new Event();

      System.out.println("Enter Details of event1:");

      event1.setEventNumber();

      event1.settotalGuests();

      System.out.println("Enter Details of event2:");

      event2.setEventNumber();

      event2.settotalGuests();

      System.out.println("Enter Details of event3:");

      event3.setEventNumber();

      event3.settotalGuests();

      display(event1);

      display(event2);

      display(event3);

      System.out.println("Get largest event from event1 and event2 is :");

      display(getLargestEvent(event1, event2));

      System.out.println("Get largest event from event2 and event3 is :");

      display(getLargestEvent(event2, event3));

      System.out.println("Get largest event from event1 and event3 is :");

      display(getLargestEvent(event1, event3));

  }

  public static void display(Event e) {

      System.out.println("Event number: " + e.getEventNumber());

      System.out.println("Total guests: " + e.gettotalGuests());

      System.out.println("Total price: $"

              + String.format("%.2f", e.getPrice()));

      System.out.println("Is Large event: " + e.isLargeEvent());

      System.out.println("");

  }

  public static Event getLargestEvent(Event e1, Event e2) {

      if (e1.gettotalGuests() > e2.gettotalGuests())

          return e1;

      else

          return e2;

  }

}

Explanation:

  • Call isLargeEvent() method to check whether to set pricePerGuest as Lower or Higher.
  • Calculate the price by multiplying the total guests with price per guest.
  • Call gettotalGuests() method to check if the event is large or small.
You might be interested in
In the context of organizational decisions at the tactical management level, _____ decisions are often used in resolving conflic
natali 33 [55]

Answer:

b. structured

Explanation:

Based on the information being described within the question it can be said that the type of decisions being mentioned are known as structured decisions. These are decisions which have various processes in place in order to handle a certain situation. Usually due to the problem having occurred countless times and are predictable.

4 0
3 years ago
Which of the descriptions listed below best describes the step in the reverse engineering process called functional analysis? A)
Zepler [3.9K]
If multiple choice then d and a if not then the best one would be a!


hope this helps!!
5 0
3 years ago
2.24 Write the relevant Python expression or statement, involving a list of numbers lst and using list operators and methods for
miskamm [114]

Answer:

lst = [11, 603, 99, 7, 582, 1];

print("The index of the middle element: " + str(int(len(lst)/2)))

print("The middle element: " + str(lst[int(len(lst)/2)]))

lst.sort()

sorted_lst = lst.reverse()

print("The list in descending order: " + str(lst))

first_number = lst.pop(0)

lst.append(first_number)

print("New lst: "+ str(lst))

Explanation:

- Initialize a list

- Find the middle index, int(len(lst)/2)

- Find the middle element, lst[int(len(lst)/2)]

- Sort the list in descending order (First sort the list in ascending order than reverse it)

- Get the first element using <em>pop</em> method, and append it to the end using <em>append</em> method

- - - - -

a) 0 == 1 == 2 --> Always evaluates false

b) 2 + (3 == 4) + 5 == 7 --> Evaluates true

c) 1 < -1 == 3 > 4 --> Always evaluates false

3 0
4 years ago
Shannon wants to work with renewable energy. She is researching what it would take to become a geochemist. A geochemist is someo
Liula [17]

Answer:

Critical thinking

Explanation:

Shannon needs to be a Critical thinker to be effective in this position. Critical thinking has to do with giving deep and good thoughts while doing analysis, or assessment in other to come up with good judgements about a subject or topic.

Since she is going to be studying water and elements in it, she would be doing a lot of analysis and assessments and In other to do good in her field she must learn to think critically before arriving at her conclusions.

3 0
4 years ago
What is the most important external issue when using social media in emergency management?
DerKrebs [107]
Th e most important external issue when using social media in emergency management is the disaster response. Disseminating information through social media is very effective especially when there are calamities and a disaster respond from both private and public sector is very urgent.
8 0
3 years ago
Other questions:
  • Send a document as a PDF when A. you want the recipient to make changes to the file. B. it needs to be printed. C. it contains m
    10·1 answer
  • To create a digital file from an old photo, I would use a _____.
    10·1 answer
  • What function does the ALU perform?
    10·1 answer
  • What is an enterprise system
    14·2 answers
  • Identify the most appropriate way to display the following research data.
    12·1 answer
  • When an object is acted on by unbalanced forces, the object will always
    11·1 answer
  • Blending two or more colours is called​
    6·1 answer
  • 1
    13·1 answer
  • GOOD EVENING, FRIENDS, I WANT TO ASK ON THE ACCOUNT OF HIS NAME‏BENJEMIN360 . THIS ANSWERS ARE VERY WONDERFUL, BUT I CAN'T COMMU
    6·1 answer
  • Write a 2 paragraph on an African American who has become successful in IT. Need help asap can’t think of anything
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!