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
Galina-37 [17]
3 years ago
5

This method will sell the seat in row i and column j unless it is already sold. A ticket is sold if the price of that seat in th

e array is 0. If the ticket is not sold, add the price of the seat in row i and column j to the totalSales and then set the price of that seat to 0 to designate it has been sold and return true since a sell was made. If the ticket was already sold, then return false.
Engineering
1 answer:
blsea [12.9K]3 years ago
8 0

Answer:

The solution code is written in Java.

  1. public class Movie {
  2.    private double  [][] seats = new double[5][5];
  3.    private double totalSales;
  4.    public Movie(){
  5.        for(int i= 0; i < this.seats.length; i++){
  6.            for(int j = 0; j < this.seats[i].length; j++){
  7.                this.seats[i][j] = 12;
  8.            }
  9.        }
  10.        this.totalSales = 0;
  11.    }
  12.    public boolean bookSeat(int i, int j)
  13.    {
  14.        if(this.seats[i][j] != 0){
  15.            this.totalSales += this.seats[i][j];
  16.            this.seats[i][j] = 0;
  17.            return true;
  18.        }else{
  19.            return false;
  20.        }
  21.    }
  22. }

Explanation:

The method, bookSeat(), as required by the question is presented from Line 16 - 26 as part of the public method in a class <em>Movie</em>.  This method take row,<em> i</em>, and column,<em> j</em>, as input.

By presuming the seats is an two-dimensional array with all its elements are  initialized 12 (Line 7 - 10). This means we presume the movie ticket price for all the seats are $12, for simplicity.

When the<em> bookSeat() </em>method is invoked, it will check if the current price of seats at row-i and column-i is 0. If not, the current price, will be added to the <em>totalSales </em>(Line 19)<em> </em>and then set the price to 0 (Line 20) and return <em>true</em> since the ticket is successfully sold (Line 21).  If it has already been sold, return <em>false</em> (Line 23).

You might be interested in
Moonbeam-Musel (MM), a manufacturer of small appliances, has a large injection molding department. Because MM's CEO, Crosscut Sa
forsale [732]

Answer: Because MM's CEO, Crosscut Sal, is a stickler for keeping machinery running, the company stocks quick-change replacement modules for the two most common ..

Explanation:

7 0
3 years ago
At a retirement party, a coworker described terry as dedicated
denis23 [38]

Answer:

At a retirement party, a coworker described Terry as dedicated, hardworking, and dependable. He also said that Terry was a great leader, knew the computer system, and kept the company's finances in order

8 0
3 years ago
Vẽ thủ tục cho một cuộc gọi thuê bao
shusha [124]

Lo siento, no sé qué estás diciendo.

8 0
3 years ago
A well insulated rigid tank contains 4 kg of argon gas at 450 kPa and 30 C. A valve is opened, allowing the argon to escape unti
natima [27]

Answer:

Final mass of Argon=  2.46 kg

Explanation:

Initial mass of Argon gas ( M1 ) = 4 kg

P1 = 450 kPa

T1 = 30°C = 303 K

P2 = 200 kPa

k ( specific heat ratio of Argon ) = 1.667

assuming a reversible adiabatic process

<u>Calculate the value of the M2 </u>

Applying ideal gas equation ( PV = mRT )

P₁V / P₂V = m₁ RT₁ / m₂ RT₂

hence : m2 = P₂T₁ / P₁T₂ * m₁

                   = (200 * 303 ) / (450 * 219 ) * 4

                   = 2.46 kg

<em>Note: Calculation for T2 is attached below</em>

5 0
3 years ago
What size resistor would produce a current flow of 5 Amps with a battery voltage of 12.6 volts​
Debora [2.8K]

Answer:

resistance = 2.52 ohms

Explanation:

from the formula

V =IR

Voltage = (current)(resistance)

Resistance =

R=

R= 2.52 ohms

5 0
3 years ago
Other questions:
  • Suppose that a wireless link layer using a CSMA-like protocol backs off 1ms on average. A packet’s link and physical layer heade
    5·1 answer
  • What is the entropy of a closed system in which 25 distinguishable grains of sand are distributed among 1000 distinguishable equ
    5·2 answers
  • suppose we number the bytes in a w-bit word from 0 (less significant) to w/8-1 (most significant). write code for the followign
    11·1 answer
  • Q#3:(A)Supose we extend the circular flow mode to add imports and export copy the circular flow digram onto a sheet paper and th
    15·1 answer
  • Do you think the industrial revolution helped or hurt workers? Why?
    8·1 answer
  • An aluminum bar 125 mm long with a square cross section 16 mm on an edge is pulled in tension with a load of 66,700 N and experi
    14·1 answer
  • What Are 2 Properties electromagnets have that permanent magnets do not?
    8·2 answers
  • Just need someone to talk to pls dont just use me for points
    5·1 answer
  • Identify renewable energy sources you will propose. Explain the key elements to your solution and the basic technical principles
    5·1 answer
  • Part A Identify the zero-force members in the truss. (Figure 1) (Hint: Use both visual inspection and analysis.) Check all that
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!