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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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