Implement a class address

Assignment Help C/C++ Programming
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.

Reference no: EM13313866

Questions Cloud

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.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a menu-driven program that maintains an address book

Write a menu-driven program that maintains an address book using a linked list. The address book must supports the following operations

  Write in c++ another overloaded operator

Write in C++ another overloaded operator to go in the program that has Treasury. Overload the forward slash /  so that in the main program, you can declare sale to be of type Treasury, and commission to be of type Treasury, and commispctage to be of ..

  A run is a sequence of adjacent repeated val

A   run   is   a   sequence   of   adjacent   repeated   values.   Using   an   array,   write   a   program   that   generates   a   sequence   of

  Method celsius return celsius equivalent of fahrenheit

Method Celsius return the Celsius equivalent of a Fahrenheit temperature,using the calculation Celsius = 5.0/9.0*(Fahrenheit -32); method Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation  Fahrenheit = 9.0/5..

  If a class is derived protected

If a class is derived protected from a base class, explain how this affects the inheritance of all public, protected, and private members of the base class by the derived class.

  Analyze the time complexity and space complexity

Develop a simple prototype version of algorithm in C++. Specifically, you will build an in-place, order reversal algorithm - analyze the time complexity and space complexity of your algorithm

  Need a program that has the user enter a string

Need a program that has the user enter a string. The program will test to see if its a exact palindrome like "civic" or "level". then it should test if its an inexact palindrome like "a nut for a jar of tuna".

  Write a switch-case programming for calculation

How to use C++ to write a switch-case programming for calculation? Test the program for a wide range of possible inputs including division by zero and square root of negative values.

  Prefetching is a technique that leverages predictable

Prefetching is a technique that leverages predictable address patterns to speculatively bring in additional cache blocks when a particular cache block is accessed. One example of prefetching is a stream buffer that prefetches sequentially adjacent..

  Using songs.dat in our folder

Using songs.dat in our folder on the P: drive, construct a playlist of 10 random songs. Use a struct to hold the song data (name and time in seconds), and output the playlist (song name and time,

  When given a c-string reference and a character

Write a program that implements and tests the following functions for use with C-strings (you may assume that  input obtained by the program is limited to a maximum of 80 characters):

  Create a road class

Create a Road class. The class should have functions for setting the width of the road in feet and the length of the road in miles. It should also have functions for obtaining the width of the road the length of the road

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd