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
For methyl chloride at 100°C the second and third virial coefficients are: B = −242.5 cm 3 ·mol −1 C = 25,200 cm 6 ·mol −2 Calcu
bogdanovich [222]

Answer:

a)W=12.62 kJ/mol

b)W=12.59 kJ/mol

Explanation:

At T = 100 °C the second and third virial coefficients are

B = -242.5 cm^3 mol^-1

C = 25200 cm^6  mo1^-2

Now according isothermal work of one mole methyl gas is

W=-\int\limits^a_b {P} \, dV

a=v_2\\

b=v_1

from virial equation  

\frac{PV}{RT}=z=1+\frac{B}{V}+\frac{C}{V^2}\\   \\P=RT(1+\frac{B}{V} +\frac{C}{V^2})\frac{1}{V}\\

And  

W=-\int\limits^a_b {RT(1+\frac{B}{V} +\frac{C}{V^2}\frac{1}{V}  } \, dV

a=v_2\\

b=v_1

Now calculate V1 and V2 at given condition

\frac{P1V1}{RT} = 1+\frac{B}{v_1} +\frac{C}{v_1^2}

Substitute given values P_1\\ = 1 x 10^5 , T = 373.15 and given values of coefficients we get  

10^5(v_1)/8.314*373.15=1-242.5/v_1+25200/v_1^2

Solve for V1 by iterative or alternative cubic equation solver we get

v_1=30780 cm^3/mol

Similarly solve for state 2 at P2 = 50 bar we get  

v_1=241.33 cm^3/mol

Now  

W=-\int\limits^a_b {RT(1+\frac{B}{V} +\frac{C}{V^2}\frac{1}{V}  } \, dV

a=241.33

b=30780

After performing integration we get work done on the system is  

W=12.62 kJ/mol

(b) for Z = 1 + B' P +C' P^2 = PV/RT by performing differential we get  

         dV=RT(-1/p^2+0+C')dP

Hence work done on the system is  

W=-\int\limits^a_b {P(RT(-1/p^2+0+C')} \, dP

a=v_2\\

b=v_1

by substituting given limit and P = 1 bar , P2 = 50 bar and T = 373 K we get work  

W=12.59 kJ/mol

The work by differ between a and b because the conversion of constant of virial coefficients are valid only for infinite series  

8 0
3 years ago
To measure the voltage drop across a resistor, a _______________ must be placed in _______________ with the resistor. Ammeter; S
gulaghasi [49]

Answer:

The given blanks can be filled as given below

Voltmeter must be connected in parallel

Explanation:

A voltmeter is connected in parallel to measure the voltage drop across a resistor this is because in parallel connection, current is divided in each parallel branch and voltage remains same in parallel connections.

Therefore, in order to measure the same voltage across the voltmeter as that of the voltage drop across resistor, voltmeter must be connected in parallel.

4 0
3 years ago
What's the monomer? Show the structure.
ivolga24 [154]

In order to understand a monomer let´s first see the structure of a polymer. As an example, in the first figure polyethylene (or polyethene) is shown. This polymer, like every other one, is composed of many repeated subunits, these subunits are called monomer. In the second figure, polyethylene's monomer is shown.  

7 0
4 years ago
A 6V battery is connected in series with two bulbs. What would the voltage drop be across each bulb?
Vitek1552 [10]

Answer:

3V

Explanation:

6 0
3 years ago
The oil system is:
kirill [66]

Answer:

From the main bearings, the oil passes through feed-holes into drilled passages in the crankshaft and on to the big-end bearings of the connecting rod.

3 0
2 years ago
Other questions:
  • A rod is 2m long at temperature of 10oC. Find the expansion of the rod, when the temperature is raised to 80oC. If this expansio
    7·1 answer
  • There are two piston-cylinder systems that each contain 1 kg of an idea gas at a pressure of 300 kPa and temperature of 350 K. T
    8·1 answer
  • A piston/cylinder contains 1.5 kg of water at 200 kPa, 150°C. It is now heated by a process in which pressure is linearly relate
    14·1 answer
  • What is the advantage of Sensabot over human inspectors?
    12·1 answer
  • 0 - 1"<br> -20<br> -15<br> -10<br> 5<br> 0 1 2 3<br> 0
    14·1 answer
  • The concrete canoe team does some analysis on their design and calculates that they need a compressive strength of 860 psi. They
    15·1 answer
  • Which is the maximum length for any opening on the surface of a 2G SMAW guided bend test specimen?
    11·1 answer
  • When nondeterminism results from multiple threads attempting to access a shared resource such as a shared variable or a shared f
    9·1 answer
  • How would I find the Voltage across the open circuit
    7·1 answer
  • Technician A says that the definition of torque is how far the crankshaft twists in degrees.Technician B says that torque can re
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!