Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help on C++ H/W. Thanks I already completed Task 1 I just need help updating it for the task 2 below Here is the

Need help on C++ H/W. Thanks

image text in transcribed

I already completed Task 1 I just need help updating it for the task 2 below

image text in transcribed

Here is the code for task 1 that needs to be updated for task 2 below

#include using namespace std;

class EncapsulationDemo { private: int size;

float* nos;

public: // Zero argumented constructor EncapsulationDemo() { } // Parameterized constructor EncapsulationDemo(int size) { this->size = size; nos = new float[size]; }

// getters and setters void setSize(int size) { EncapsulationDemo ed(size); this->size = size; }

int getSize() { return size; } /* Getting the nos entered by the user and * populate those values into an array */ void inputNos() { for (int i = 0; i > nos[i]; } }

// this function will calculate the sum of the array nos float calSum() { float tot = 0.0; for (int i = 0; i

// this function will calculate the average of the array nos float calAvg() { return calSum() / size; }

// this function will display the array nos void displayNos() { cout

// Getting the input entered by the user cout > size;

// creatingan instance of class EncapsulationDemo ed(size);

// calling the functions ed.inputNos(); ed.displayNos(); float sum = ed.calSum(); float avg = ed.calAvg();

// displaying the output cout Use Object Oriented Program design to solve the problems below Encapsulation Example Classes / Methods / etc. Task 1 Write a program that uses an array to find the Average of a set float values entered by the user. You will have the main function control the operation of the program, but all values will be stored in the class. You will need to use get and set methods in your class. Create an array as a member of the class Create 1 method to handle user input. Create 1 method to sum all numbers in array Create 1 method to output the average of all numbers input by the user. Create 1 method to output all the numbers input by the user. Attach Snipping photos of source code and output. Please show output of all methods executing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions