Chat with us, powered by LiveChat NumberList | WriteDemy

Question Description

C++ NumberList program based on the files i've shared at the bottom.

NumberList.cpp

************************************************************************************************

#include "NumberList.h"

#include <iostream>

using namespace std;

NumberList::NumberList()

{

length = 10;

int i;

for(i = 0; i < length; i++)

Numbers[i] = 0;

}

//outputs the numbers in the NumberList horizontally each separated by a comma

//to the standard output screen

NumberList::NumberList(int l, double n)

{

int i;

for(i = o < length-1; i++)

cout << Numbers[i] << ", ";

cout << Numbers[i];

}

//assignment constructor, initializes length to l

//and sets the first l values of the list to the value n

NumberList::NumberList(int l, const double a[])

{

length = i;

int i;

for(i = 0; i < length; i++)

Numbers[i] = n;

}

NumberList::NumberList(const NumberList & nl)

{

}

/*

void NumberList::print()

{

}

int NumberList::getLength()

{

}

double NumberList::sum()

{

}

double NumberList::ave()

{

}

double NumberList::max()

{

}

double NumberList::min()

{

}

bool NumberList::isIn(double n)

{

}

bool NumberList::push(double value)

{

}

bool NumberList::pop()

{

}

void NumberList::read(istream & inStream)

{

if(&inStream == &cin)

{

}

else

{

//file structure: first line contains the number of numbers in the list

//remaining lines contain the numbers each separated by a whitespace

}

}

bool NumberList::insert(double number, int position)

{

}

//SELECTION SORT algorithm

void NumberList::sort(char type)

{

}

bool NumberList::operator==(const NumberList& rhs)

{

}

NumberList& NumberList::operator=(const NumberList& rhs)

{

//avoid self-assignment, only do assignment if RHS is a different object from this

if(this != &rhs)

{

}

return *this;

}

NumberList& NumberList::operator+=(const double& number)

{

if(length == 100)

cout << "Unable to perform +=, list is filled to capacityn";

else

{

}

return *this;

}

NumberList& NumberList::operator+=(const NumberList& rhs)

{

if(length == 100)

cout << "Unable to perform +=, list is filled to capacityn";

else if(length + rhs.length > 100)

cout << "Unable to perform +=, list would be over capacityn";

else

{

}

return *this;

}

//**************************************

//FOR 10% EXTRA CREDIT ON THIS PROJECT GRADE, OVERLOAD THE FOLLOWING OPERATORS

//AS NON-MEMBER FUNCTIONS

ostream& operator<<(ostream& out, const NumberList& nl)

{

}

const NumberList operator+(NumberList& lhs, const double& number)

{

}

const NumberList operator+(NumberList& lhs, const NumberList& rhs)

{

}

*/

************************************************************************************************************************

NumberList.h

*************************************************************************************************************************

#ifndef NUMBERLIST_H_

#define NUMBERLIST_H_

#include <iostream>

using namespace std;

//integer constant that determines the size (max capacity) of the array

const int MAX_CAPACITY = 100;

//This class will be used to store an ordered list of real numbers. The size of the list is

//determined by the integer constant MAX_CAPACITY, for this project it will be set to 100

class NumberList

{

private:

//the number of valid numbers currently in the NumberList stored in sequential

//position order.

int length;

//static array used to store the numbers

double numbers[MAX_CAPACITY];

public:

//default constructor, initializes all values of the list to 0

//and sets length to 10

NumberList();

//assignment constructor, initializes length to l

//and sets the first l values of the list to the value n

NumberList(int l, double n);

//constructor that takes an array of size l as input and assigns the first

//l values of the NumberList to the corresponding l values of the input array a

NumberList(int l, const double a[]);

//copy constructor, creates a copy of input NumberList nl to the calling

//NumberList

NumberList(const NumberList& nl);

//outputs the numbers in the NumberList horizontally each separated by a comma

//to the standard output screen

void print();

int getLength(); //returns the length of the NumberList

double sum();//returns the sum of the numbers in the NumberList

double ave();//returns the average value of the numbers in the NumberList

double max();//returns the largest number in the NumberList

double min();//returns the smallest number in the NumberList

//Uses a sequential/linear search algorithm to determine if a number is in the

//list. Returns true if number n is in list, otherwise returns false

bool isIn(double n);

//stores a value at the end of the NumberList, returns true if successful,

//otherwise returns false (THE NUMBERLIST IS FILLED TO CAPACITY)

bool push(double value);

//removes last element in the NumberList, returns

//true if successful otherwise returns false (THE NUMBERLIST IS EMPTY)

bool pop();

//reads numbers from an input stream. If a file stream is used then

//the file structure is as follows: first line contains the number of numbers in

//the list remaining lines contains a maximum of 10 numbers each separated by a

//whitespace

void read(istream & inStream);

//inserts a number in an ordinal position and shifts each number to the right of

//the ordinal position by one. Returns true if successful, otherwise

//if THE NUMBERLIST IS FILLED TO CAPACITY returns false. EXAMPLE: If the list

//contains the values < 2, 7, -9, 11 > after the call N.insert(8, 2) is made, the

//list will then be < 2, 8, 7, -9, 11 >. If position is greater than the current

//length of the list, then the insert will occur at the end. EXAMPLE: If the list

//contains the values < 2, 7, -9, 11 > after the call N.insert(8, 13) is made, the

//list will then be < 2, 7, -9, 11, 8 >.

bool insert(double number, int position);

//sorts the numbers in the list using the SELECTION SORT algorithm.

//Type is either 'A','a' for ascending, or 'D','d' for descending

void sort(char type);

/********OVERLOADED OPERATORS**********/

//determines if two number lists are identical

//identical implies the same numbers in the same positions

bool operator==(const NumberList& list);

//assign one NumberList to another NumberList

NumberList& operator=(const NumberList& rhs);

//add a number to the end of a NumberList using the compound addition operator

NumberList& operator+=(const double& number);

//add two Numberlists using the compound addition operator

NumberList& operator+=(const NumberList& rhs);

/******************************************************************************/

//FOR 10% EXTRA CREDIT ON THIS PROJECT GRADE, OVERLOAD THE FOLLOWING OPERATORS

//AS NON-MEMBER FUNCTIONS

//(1) << (insertion)

friend ostream& operator<<(ostream&, const NumberList&);

//(2) + (addition) that adds one element to the end of a list

friend const NumberList operator+(NumberList& lhs, const double& number);

//(3) + (addition) that adds two lists (LIST CONCATENATION)

friend const NumberList operator+(NumberList& lhs, const NumberList& rhs);

//HINT: to overload both addition operators as stated above, use the overloaded

//functions += that presumably, you have already implemented

/******************************************************************************/

};

#endif /* NUMBERLIST_H_ */

************************************************************************************************************************************

testNL.cpp

************************************************************************************************************************************

#include "NumberList.h"

#include <iostream>

#include <cctype>

using namespace std;

int main()

{

}

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order