A theater seating chart is implemented as a two-dimensional


Problem 1:

Write a program that initializes an array with ten random integers and then prints out the following:

• Every element at an even index;
• Every even element
• All elements in reverse order;
• Only the first and last elements;
• The minimum and maximum element
• The sum of all elements
• The alternating sum of all elements, where the alternating sum contains all elements at even index added, and the elements at odd index subtracted.

Problem 2:

Write a program that reads a sequence of input values and displays a bar chart of the values in data, using asterisks, like this:

*********************
*************************
*********
**************************

You may assume that all values are positive. First figure out the maximum value in data. That value's bar should be drawn with 40 asterisks. Shorter bars should use proportionally fewer asterisks. Improve your program by adding caption to your bar. Prompt the user for the captions and data values. The output should look like this:

Egypt *********************
France *************************
Norway *********
Germany **************************

Problem 3:

A theater seating chart is implemented as a two-dimensional array of ticket prices like presented below. Write a program that prompts the users to pick either a seat or a price. Mark sold seats by changing the price to zero. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price. Verify that the price is among those offered by the theater.

10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
20 20 30 30 40 40 30 30 20 20
20 30 30 40 50 50 40 30 30 20

Problem 1:

Implement a class Address. An address has a house number, a street, an optional apartment number, a city, a state, and a postal code. Supply two constructors: one with an apartment number and one without. Supply a print method that prints the address with the street on one line and the city, state, and postal code on the next line. Supply a method public booleancomesBefore (Address other) that tests whether this address comes before another when the addresses are compared by postal code.

Problem 2:

Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a method drive that simulates driving the car for a cartain distance, reducing the fuel level in the gas tank, and methods getGasLevel, to return the current fuel level and addGas, to tank up. Sample usage:

Car myHybrid = new Car(50); //50 miles per gallon
myHybrid.addGas(20); // Tank 20 gallons
myHybrid.drive(100); // Drive 100 miles
System.out.println(myHybrid.getGasLevel()); // Print fuel remaining.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: A theater seating chart is implemented as a two-dimensional
Reference No:- TGS0652546

Now Priced at $70 (50% Discount)

Recommended (94%)

Rated (4.6/5)