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
Define Plastic vs elastic deformation.
Snowcat [4.5K]

Answer:

Plastic deformation, irreversible or permanent. Deformation mode in which the material does not return to its original shape after removing the applied load. This happens because, in plastic deformation, the material undergoes irreversible thermodynamic changes by acquiring greater elastic potential energy.

Elastic deformation, reversible or non-permanent. the body regains its original shape by removing the force that causes the deformation. In this type of deformation, the solid, by varying its tension state and increasing its internal energy in the form of elastic potential energy, only goes through reversible thermodynamic changes.

3 0
3 years ago
A 20.0 µF capacitor is charged to a potential difference of 800 V. The terminals of the charged capacitor are then connected to
Sergeu [11.5K]

Answer:

a) Q_initial = 16 * 10^-3 C

b) V_1 = V_2 =  (16/3) * 10^2 V

c)  E = 64/15 J

d)  dE = 32/15 J of decrease

Explanation:

Given:

- Capacitor 1, C_1 = 20.0 uF

- Capacitor 2, C_2 = 10.0 uF

- Charged with P.d V = 800 V

Find:

a) the original charge of the system,

(b) the final potential difference across each capacitor

(c) the final energy of the system

(d) the decrease in energy when the capacitors are connected.

Solution:

a)

- The initial charge in the circuit is the one carried by the first charged capacitor.

                           Q_initial = C_1*V

                           Q_initial = 20*10^-6 * 800

                           Q_initial = 16 * 10^-3 C

b)

- After charging the other capacitor, we know that the total charge is conserved among two capacitor:

                          Q_initial = Q_1 + Q_2

- We also know that potential difference across two capacitor is also same.

                          V_1 = V_2 = Q_1 / C_1 = Q_2 / C_2

- Using the two equations and solve for charge Q_2:

                          Q_2 = Q_1*C_2/C_1

                          Q_2 = Q_1*10/20 = 0.5*Q_1

- using conservation of charge:

                          Q_initial = 1.5*Q_1

                          Q_1 = 16*10^-3 / 1.5 = 10.67*10^-3 C

- Hence the Voltage across each capacitor is:

                          V_2 = V_1 = Q_1 / C_1  

                                            = 10.67*10^-3 / 20*10^-6

                                            = (16/3) * 10^2 V

c)

- The energy in the system is:

                          E = 0.5*C_eq*V^2

Where, C_eq is the equivalent capacitance of paralle circuit.

                           E = 0.5*(20+10)*10^-6 *((16/3) * 10^2)^2

                          E = 64/15 J

d)

- The decrease in energy of the capacitors is:

                           dE = E_initial - E_final

Where, E_initial is due to charging of the C_1 only:

                          dE = 0.5*10^-6*20*800^2 - (64/15)

                          dE = 32/5 - 64/15 = 32/15 J

5 0
3 years ago
X+3=2<br>x=??<br><br><br><br>No spamming​
PtichkaEL [24]

Answer:

x+3=2

x=2-3꧁

꧁꧁꧂꧂꧂꧂

x=-1

4 0
3 years ago
How can we calculate the speed of the output gear in a simple gear train? Explain with the help of an example.
Snowcat [4.5K]

Answer:

N_3=\dfrac{T_1}{T_3}N_1

Explanation:

In the diagram there three gears in which gear 1 is input gear ,gear 2 is idle gear and gear 3 is out put gear.

Lets take

Speed\ of\ gear 1=N_1

Number\ of\ teeth\ of\ gear 1=T_1

Speed\ of\ gear 3=N_3

Number\ of\ teeth\ of\ gear 3=T_3

All external matting gears will rotates in opposite direction with respect to each other.

So the speed of gear third can be given as follows

\dfrac{T_1}{T_3}=\dfrac{N_3}{N_1}

N_3=\dfrac{T_1}{T_3}N_1

3 0
3 years ago
When measuring a Brake Drum, the Brake Micrometer is set to a Base Drum Diameter of 10 Inches plus four notches, and the dial re
kozerog [31]

Answer:

10.5

Explanation:

7 0
3 years ago
Other questions:
  • 5. Which of these least accurately describes what happens when abnormal combustion raises the temperature and pressure inside th
    8·1 answer
  • The idling engines of a landing turbojet produce forward thrust when operating in a normal manner, but they can produce reverse
    7·1 answer
  • Your new mobile phone business is now approaching its first anniversary and you are able to step back and finally take a deep br
    8·1 answer
  • 12. Dies are turned using a special tool called a/an
    10·1 answer
  • Air enters the compressor of an ideal Brayton refrigeration cycle at 100 kPa, 270 K. The compressor pressure ratio is 3, and the
    13·1 answer
  • How can goal setting help with academic performance?
    13·1 answer
  • E xercise 17.1.2: For each of the transactions of Exercise 17.1.1, add the read- and write-actions to the computation and show t
    12·1 answer
  • You are hired as the investigators to identify the root cause and describe what should have occurred based on the following info
    9·1 answer
  • For somebody
    12·1 answer
  • Cody’s car accelerates from 0m/s to 45 m/s northward in 15 seconds. What is the acceleration of the car
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!