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

  Const int num_years

How do you get this program to get both player input and then display results(As described on bottom) #include  const int NUM_YEARS=15;//The number of years const int NAME_SIZE=32;//The max size of the player name string

  Write c++ program to create a bar chart showing the average

Write a c++ program to create a bar chart showing the average monthly mean temperature for College Station from 2004 to 2013.

  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.

  An integer on this system is 4 bytes long

Assume the following for the program below. An integer on this system is 4 bytes long. The memory address where the array "a[]" was created begins at location 8000. a. #include

  Uml diagram of all the classes

Speaking of converting into the correct object-type, the goal of the factory is to abstract away object creation.

  Inserts a node with info value x

Complete the code for a function that inserts a node with info      value x before, and a node with info value zafter,each node with      info value y in a linked list with first node pointer p.

  The "continue" and "break" statements

How are the "continue" and "break" statements different from the "exit" and "return" statements?

  Create a calling module name and parameters

Create a calling module name and parameters for the following. (Remember that the asterisk before the parameter name indicates a call-by-reference parameter.

  Pointer variables to demonstrate shallow and deep copy

Using C++, write a program that uses pointer variables to demonstrate shallow and deep copy. The program should give the user the choice to do the following:

  Prompts the user to enter the mass of a person

Write a program that prompts the user to enter the mass of a person in kilograms and outputs the equivalent weight in pounds. Output both the mass and the weight rounded to two decimal places

  Explain how to convert c program to mips program

Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3 already.

  Create a structure that has one variable called value

"Create a structure that has one variable called value and one pointer to the list (making it a linked list). Prompt for 5 values from the keyboard as input and store them in the linked list. Print out the current contents of the list.

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