CSC 1310 In-Class Practice

$30.00 $24.00

Take your Planet program that you have created in past classes and add to it. Create an overloaded, inline constructor for the Planet class that will accept the radius as a parameter and will set minSurfaceTemp & maxSurfaceTemp to 0.0, but set radius to the value sent to the constructor. Add a cout statement in…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

  1. Take your Planet program that you have created in past classes and add to it.
  2. Create an overloaded, inline constructor for the Planet class that will accept the radius as a parameter and will set minSurfaceTemp & maxSurfaceTemp to 0.0, but set radius to the value sent to the constructor. Add a cout statement in the constructor that says “Creating a Planet with an overloaded constructor!”
  3. Create two friend functions for the Planet class.
    1. overloaded << operator, which will print a Planet object in the following format:
      Min Surface Temp: 12.4
      Max Surface Temp: 98.3
      Radius: 39485.2
    2. overloaded + operator, which will accept two Planets as arguments and create a new Planet with the combined radius of the two given Planets
  4. Create a template class called AddPrint.
    1. This class should not have any attributes
    2. There should be two functions: add & print
    3. Add should accept two parameters – both of the template type – add them together and then return the result
    4. Print should accept one parameter of the template type and print it out. It is a void function.
  5. Use the provided Driver.cpp in the Chapter 2 module under content in ilearn to test your program.
  6. Create a Makefile to compile your program.

Sample Output

Creating a Planet!

Creating a Planet!

Give me an integer: 7

Give me another integer: 4

The numbers added together is 11

7

4

——————————————–

What is the min surface temp of planet 1? 12.4

What is the max surface temp of planet 1? 98.3

What is the radius of planet 1? 39485.2

What is the min surface temp of planet 2? 4.3

What is the max surface temp of planet 2? 193

What is the radius of planet 2? 333.1

Creating a Planet with an overloaded constructor!

The radius of the two planets added together is 39818.3

Planet One:

Min Surface Temp: 12.4

Max Surface Temp: 98.3

Radius: 39485.2

Planet Two:

Min Surface Temp: 4.3

Max Surface Temp: 193

Radius: 333.1

CSC 1310 In-Class Practice
$30.00 $24.00