Question: A class for an experiment. Each experiment will need appropriate fields (with appropriate types) for the following: Experiment Name (Max 30 Characters) Experiment Date (as

A class for an experiment. Each experiment will need appropriate fields (with appropriate types) for the following:

  • Experiment Name (Max 30 Characters)
  • Experiment Date (as characters, Max 30 characters)
  • Number of trials
  • An array of unknown size for the values received from a trial of the experiment (the values will be numbers with a decimal place)

Additionally, each experiment has the following functions that need to be implemented:

  • Experiment(): a constructor that receives one parameter for the number of trials. If the number is 0 or less, the number of trials should be set to 0 (safe empty state), and the array should be set to a safe empty state. If the number of trials parameter is 1 or more, then the number of trials should be set to the parameter that was passed, and the array should be allocated.
  • Double averageValues(): this function will calculate the average of the values stored in the array and return the average
  • Double maxValue(): this function will find the maximum value stored in the array and return the maximum value
  • Double minValue(): this function will find the minimum value stored in the array and return the minimum value
  • Overload the bool operator to return whether the number of trials is greater than 0 (ie if an experiment has 1 or more trials, then the experiment is valid)
  • Void display() const: this function will output the fields of the object. Any time a number with a decimal is output, there should be a MAX of 3 decimal places output
    • Example Format:

Experiment Name: [name]

Experiment Date: [date]

Number of trials: [value]

The average experiment value: [value]

The maximum experiment value: [value]

The minimum experiment value: [value]

It needs to be 2 files , a header (.h) file with your class definiton, and a c++ (.cpp) file that contains your class function declarations.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!