Question: Instructions: Copy the file Lab11.cpp from the CS121 folder on my S drive to your folder Create a project, called Lab11 make it an EMPTY

Instructions:

Copy the file Lab11.cpp from the CS121 folder on my S drive to your folder

Create a project, called Lab11 make it an EMPTY project.

open the file Lab11.cpp make sure you open your copy

move the file Lab11.cpp into the project

Create a header file, called group.h

Remove the class definition from the lab11.cpp and paste it into the header file

Create an implementation file, called groupimp.cpp

Include this file in the project

In this file, write the definitions of the class functions

Compile the program

Fix any syntax errors

This is the .cpp file.

// Lab 11

// Fall 2015

#include

using namespace std;

class group

{

public:

int smallest(); // function to find the smallest element of the array

int biggest(); // function to find the biggest element of the array

int position(int); // function which returns the position of the parameter value

// (-1 if not in the array)

void assignVals(); // function which asks the user for values to put in the array

void printVals(); // function which prints the values in the array

group(); // The default constructor,

// every element of the array will be set to zero

group(int); // constructor which sets every element of the array to the parameter

private:

static const int SIZE = 10; // Initializes the constant SIZE to 10

int members[SIZE]; // an array of integers

};

int main()

{

int num, pos;

group numbers;

group numbers2(5);

numbers.printVals();

numbers2.printVals();

numbers.assignVals();

numbers2.assignVals();

cout << "What number are you looking for? ";

cin >> num;

pos = numbers.position(num);

if(pos == -1)

cout << "The number " << num << "is not in the first group ";

else

cout << "The number " << num << "is at position " << pos << " of the first group ";

pos = numbers2.position(num);

if(pos == -1)

cout << "The number " << num << " is not in the second group ";

else

cout << "The number " << num << " is at position " << pos << " of the second group ";

cout << "The smallest value in the group is: " << numbers.smallest() << endl;

cout << "The largest value in the group is: " << numbers.biggest() << endl;

cout << "The smallest value in the second group is: " << numbers2.smallest() << endl;

cout << "The largest value in the second group is: " << numbers2.biggest() << endl;

numbers.printVals();

numbers2.printVals();

return 0;

}

// You need to define the 2 constructors AND the member functions of the class 'group'.

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 Databases Questions!