Engineering-Computation Homework 5 Solved

30.00 $

Description

Rate this product

1. Warmupwithpointers:

  1. Createtwointegervariablesnamedxandy;
  2. Createanintpointernamedp1;
  3. Store the address of x in p1;
  4. Useonlyp1(notx)tosetthevalueofxto99;
  5. Usingcoutandx(notp1),displaythevalueofx;
  6. Using cout and the pointer p1 (not x), display the value of x;
  7. Storetheaddressofyintop1;
  8. Useonlyp1(noty)tosetthevalueofyto-300.

2. UpdatingVehicleandTruckclasses:

  1. TakeyourVehicleclassfromHomework4andaddaprivatemember variable ‘value_date’.
    *Note: C++ has no good time and date classes (that I’ve found; you are welcome to look yourself–there is ‘ctime’). Python is the ruler for timestamp methods as it is used often in data science. Therefore, make your ‘value_date’ variable a float with decimals for partial years. In other words, if the value was evaluated on April 1, 2018, you would use the number 2018.25 to record that date and time.
  2. UpdateyourconstructorsintheVehicleandTruckclassesby including the value_date parameter (for the default value_date use February 27, 2019).
  3. Add a getter method for value_date.
  4. AddaVehiclememberfunctioncalled‘updateValue’whichtakesone

    parameter (current date). This function should depreciate the value by 15% each year, and update the value and value_date private members accordingly.

  5. AddaVehiclememberfunctioncalled‘estimateValue’whichtakes one parameter (estimated date) and returns the estimated value at a future date. This function should still depreciate the value by 15%

each year, but NOT update the value and value_date private

members.

  1. Construct a 2015 4×4 Chevrolet Colorado with 0 miles and 5000 lbs

    towing capacity, purchased for $37,000 on July 1, 2015.

  2. Updatethevalueofthe2015ColoradoonFebruary27,2019using

    the updateValue member function. Show that the value and

    value_date have been updated properly.

  3. Don’tforgettoupdateyourconstmemberfunctions(addconstto

    those that don’t change member variables).

3. VectorofTruckspassedby(const)reference:

  1. CreateyourfiveTrucksfromHomework4,withthevalue_dateequal to the date you previously estimated their value.
  2. Createaglobalfunctioncalled‘estVal’whichtakesaTruckvector const reference (const&) and a float const reference (const&). Note that the const is on the reference, not the vector or float. ‘estVal’ will return a float vector.
  3. Pass your Truck vector (created in 3a) with the estimated date April 1, 2022. In the function calculate the estimated value for each Truck in the vector and store it in the corresponding element in the float vector which will be returned.
  4. Inthemainfunction,printoutthefiveestimatedvaluescalculated and returned by ‘estVal’.

Attach your source code, screenshots of output, and header (if used) files. Include compiled executables if you wish.

  • HW5-7wwfvs.zip