Reference no: EM13313866
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.
What is the denstiy of the fluid
: A cubical box .2 m on a side is completely immersed in a fluid. The pressure at the top of the box is 105 kPA, What is the denstiy of the fluid
|
Explain moles of sodium hypochlorite needed to prepare
: Given that the Ka for hypochlorous acid is 3.0x10^-8 determine the number of moles of sodium hypochlorite needed to prepare this solution.
|
Determine what would be the carbon emission rate
: Suppose in 100 years energy consumption is still 330 Ej/yr, but coal supplies only 20 percent of total demand, natural gas supplies 30 percent, and oil 10 percent. The remaining 40 percent of demand is met by noncarbon-emitting sources.
|
Analyse the different tools available to a judge
: Analyse the different tools available to a judge to interpret the law. To what extent the tools are used effectively by judges?
|
Implement a class address
: 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.
|
How to calculate the cell potential for the reaction
: Calculate the cell potential for the following reaction as written at 69 °C, given that [Mg2 ] = 0.876 M and [Fe2 ] = 0.0160 M. Standard reduction potentials can be found here.
|
Determine the irr of building the corrosion-resistant tower
: HZ Wireless must rebuild a cell tower recently destroyed by a tornado. A tower made of normal steel (NS) will cost $30,000 to construct and should last 15 years. Maintenance will cost $1000 per year.
|
Explain the electrode follows the nernst equation
: Assume that the electrode follows the Nernst equation, the temperature is at 25°C, and that the activity coefficient of X is 1.
|
Determine the new value of l if the flowrate stayed the same
: When a channel of triangular cross section was new, a flowrate of Q caused the water to reach L = 2 m up the side of the channel. After considerable use, the walls of the channel became rougher and the Manning coefficient, n, doubled.
|