Define a class called BoxOffice that keeps track of two theatres for which it se
ID: 3637779 • Letter: D
Question
Define a class called BoxOffice that keeps track of two theatres for which it sells movie tickets. Thecost of a movie ticket is $6.25 for children under 12 years old, $5.75 for adults 65 years old or more
and $12.50 for everyone else. The box office should also keep track of the movie that has made the
most money in the past.
Carefully examine the test program below. Understand how it is supposed to work. Then write the
necessary methods so that the code runs properly, producing the correct results. You may NOT
alter the test program ... the TA will be using it to test your code. Note that when tickets are sold to
patrons, the title of the movie is provided. You will need to determine which theatre that movie is
playing in. As a hint, you can compare two strings using the .equals() method in JAVA as follows:
String s1 = ...;
String s2 = ...;
if (s1.equals(s2))
...;
else
...;
Note as well in the program below that the bestMovie() will either be a previous movie that had the
most earnings or one of the current playing movies ... whichever has the most earnings.
Explanation / Answer
private void quicksort(int low, int high) { int i = low, j = high; // Get the pivot element from the middle of the list int pivot = numbers[low + (high-low)/2]; // Divide into two lists while (i <= j) { // If the current value from the left list is smaller then the pivot // element then get the next element from the left list while (numbers[i] < pivot) { i++; } // If the current value from the right list is larger then the pivot // element then get the next element from the right list while (numbers[j] > pivot) { j--; } // If we have found a values in the left list which is larger then // the pivot element and if we have found a value in the right list // which is smaller then the pivot element then we exchange the // values. // As we are done we can increase i and j if (i <= j) { exchange(i, j); i++; j--; } } // Recursion if (low < j) quicksort(low, j); if (i < high) quicksort(i, high); } private void exchange(int i, int j) { int temp = numbers[i]; numbers[i] = numbers[j]; numbers[j] = temp; } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.