Question

%%%%% c++ assignment %%%%%% ///////// please test your program and check for errors. //////// you should...

%%%%% c++ assignment %%%%%%

///////// please test your program and check for errors.

//////// you should use the file bellow

For this assignment you will write a program that creates a tree of "plants". Each plant is the result of an exeperiment. I have provided the main driver program that is responsible for running each of the experiments but you will need to create a tree for storing the results. The objective of this assignment is to learn how to implement and use a binary tree (not a binary search tree). Since this is the objective, you cannot use a premade classes. Each plant, in this assignment, has three important factors that determine how well the plant can be used to generate enough food for the colony. The three factors are the growth rate, nutritional value, and water requirements. The higher a score for any of these factors, the more desireable the plant is. Each plant has been genetically modified so that when it reproduces it creates exactly two new plants. The new plants have different values for each of the important factors. This assignment runs a couple of experiments with different starting plants. Each experiment starts with a plant and then finds the children for that plant. Then it finds the children for each of those, and so on. As it finds the children it stores them in a binary tree with the starting plant as the root. The experiment has a depth limit and only runs the specified number of generations. When all of the reproduction is done (for the specified number of generations), the program searches the result tree to find the best plant for each of the given factors. The output of the program is the full reproduction tree and a display of the best of each of the factors.

---------------------------------------------------

Program Design

Your program should use good design methodologies so you should have separate classes for each of the following:

- plant -- This class represents a plant. Each plant has an ID as well as a growth rate factor, nutritional value factor, and water requirement  factor. The plant class should have these data members. The plant ID follows the format "Plant ??-??-??" where the first two digits are the growth value, the second two are the nutritional value, and the third two are the water requirements value.

- planttree -- This is a tree that holds the plant data. Each non-leaf node in this tree will have exactly two children. The children are not sorted in any way. The planttree class has a method for setting the root of the tree as well as setting the children for a given node. See the experiments.cpp file to see what the method signature is for each of these.

- treenode -- this will be a class (or struct, your choice) to hold a plant object and the two children pointers.

Finally, for your convenience I have provided a "makefile". If you name all of your files the same as I have then you can use the makefile to simplify your building and testing.

---------------------------------------------------------

External Requirements

- The main driver (experiments.cpp) will run a series of experiments with a couple different starting plants. The output from your program must match expected.txt exactly.

----------------------------------------------------------------

Internal Requirements

- The program must use the supplied experiments.cpp file, unmodified, as the main driver.
- The program must use a binary tree, that you implement, to store the experiment results. All results should be stored in the tree before it is printed and before the best plants are found.
- The plant class should not have any pointers to other plant classes in it.
- The planttree nodes should not contain parent pointers. That is, each node in the tree should only have two pointers -- one for left and one for right.
- The should be no memory leaks or memory errors (as repoted by valgrind)
- All "string" data should be stored as char* variables. DO NOT USE std::string.
- Any classes that contain pointers as data members must have a copy constructor, assignment operator, and destructor.

----------------------------------------------------------------

experiments.cpp

#include <iostream>

#include <cmath>

#include "plant.h"

#include "planttree.h"

using namespace std;

void showResults(planttree pt)

{

pt.display();

const plant* bestPlant;

cout << endl;

cout << "Best growth rate: " << endl;

bestPlant = pt.findBestGrowth();

if (bestPlant != nullptr)

cout << (*bestPlant) << endl;

else

cout << "ERROR: null best plant" << endl;

cout << "Best nutritional value: " << endl;

bestPlant = pt.findBestNutrition();

if (bestPlant != nullptr)

cout << (*bestPlant) << endl;

else

cout << "ERROR: null best plant" << endl;

cout << "Best water requirement: " << endl;

bestPlant = pt.findBestWater();

if (bestPlant != nullptr)

cout << (*bestPlant) << endl;

else

cout << "ERROR: null best plant" << endl;

}

plant getChildPlant(plant parent,int co[])

{

int gx = parent.getGrowth() - 50;

int nx = parent.getNutrition() - 50;

int wx = parent.getWater() - 50;

gx = abs(co[0] * (gx * gx * gx) + co[1] * ( gx * gx ) + co[2] * gx + co[3]);

gx = gx % 100;

nx = abs(co[4] * (nx * nx * nx) + co[5] * ( nx * nx ) + co[6] * nx + co[7]);

nx = nx % 100;

wx = abs(co[8] * (wx * wx * wx) + co[9] * ( wx * wx ) + co[10] * wx + co[11]);

wx = wx % 100;

char* plantId = new char[15]; // max size ==> Plant ??-??-?? == 15 chars

sprintf(plantId,"Plant %d-%d-%d",gx,nx,wx);

plant plant(plantId,gx,nx,wx);

delete [] plantId;

return(plant);

}

void runSingleExperiment(planttree& pt,int depth,plant& parentPlant)

{

if (depth > 0)

{

int leftCoeffs[] = {13,3,11,7,2,23,5,29,3,37,11,13};

int rightCoeffs[] = {128,16,64,2,32,8,2,128,256,16,16,64};

plant leftPlant = getChildPlant(parentPlant,leftCoeffs);

plant rightPlant = getChildPlant(parentPlant,rightCoeffs);

pt.addChildren(parentPlant,leftPlant,rightPlant);

runSingleExperiment(pt,depth-1,leftPlant);

runSingleExperiment(pt,depth-1,rightPlant);

}

}

void runExperiment(const char* title, plant startingPlant, int depth)

{

planttree pt;   

pt.setRoot(startingPlant);

runSingleExperiment(pt,depth,startingPlant);

cout << "===================================" << endl;

cout << title << endl;

cout << "===================================" << endl;

showResults(pt);

cout << endl;

cout << endl;

}

int main()

{

runExperiment("Experiment 1",plant("Plant 1-1-1",1,1,1),5);

runExperiment("Experiment 2",plant("Plant 11-17-33",11,17,33),5);

  

return(0);

}

-------------------------------------------------------------------

Expected.txt

// some data of the output

===================================
Experiment 1
===================================
Plant ID: Plant 1-1-1 (G: 1 N: 1 W: 1)
Plant ID: Plant 66-91-36 (G: 66 N: 91 W: 36)
Plant ID: Plant 99-39-21 (G: 99 N: 39 W: 21)
Plant ID: Plant 86-95-56 (G: 86 N: 95 W: 56)
Plant ID: Plant 19-79-59 (G: 19 N: 79 W: 59) Plant ID: Plant 58-0-8 (G: 58 N: 0 W: 8)

..

..

..

..

Plant ID: Plant 82-51-8 (G: 82 N: 51 W: 8)
Plant ID: Plant 66-50-16 (G: 66 N: 50 W: 16)
Plant ID: Plant 74-72-12 (G: 74 N: 72 W: 12)
Plant ID: Plant 11-67-93 (G: 11 N: 67 W: 93)
Plant ID: Plant 26-80-72 (G: 26 N: 80 W: 72)

Best growth rate:
Plant ID: Plant 99-39-21 (G: 99 N: 39 W: 21)
Best nutritional value:
Plant ID: Plant 82-99-88 (G: 82 N: 99 W: 88)
Best water requirement:
Plant ID: Plant 34-95-96 (G: 34 N: 95 W: 96)

===================================
Experiment 2
===================================
Plant ID: Plant 11-17-33 (G: 11 N: 17 W: 33)
Plant ID: Plant 6-63-20 (G: 6 N: 63 W: 20)
Plant ID: Plant 61-75-17 (G: 61 N: 75 W: 17)
Plant ID: Plant 94-79-68 (G: 94 N: 79 W: 68)
Plant ID: Plant 91-95-95 (G: 91 N: 95 W: 95)

..

..

..


Plant ID: Plant 58-20-48 (G: 58 N: 20 W: 48)
Plant ID: Plant 43-21-15 (G: 43 N: 21 W: 15)
Plant ID: Plant 82-51-72 (G: 82 N: 51 W: 72)
Plant ID: Plant 66-50-96 (G: 66 N: 50 W: 96)
Plant ID: Plant 74-32-52 (G: 74 N: 32 W: 52)
Plant ID: Plant 11-73-7 (G: 11 N: 73 W: 7)
Plant ID: Plant 26-40-8 (G: 26 N: 40 W: 8)

Best growth rate:
Plant ID: Plant 94-79-68 (G: 94 N: 79 W: 68)
Best nutritional value:
Plant ID: Plant 50-99-36 (G: 50 N: 99 W: 36)
Best water requirement:
Plant ID: Plant 66-50-96 (G: 66 N: 50 W: 96)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code Screenshot:

plant.h


plant.cpp


planttree.h



planttree.cpp




Copyable Code:
***************************************************************************************

plant.h

#ifndef plant_h
#define plant_h

#include <iostream>

using namespace std;
class plant
{
string id;
int growth;
int nutrition;
int water;
  
public:
plant();
plant(string id, int growth, int nutrition, int water);
plant(const plant &p);
string getId() const;
int getGrowth() const;
int getNutrition() const;
int getWater() const;
void setId(string id);
void setGrowth(int g);
void setNutrition(int n);
void setWater(int w);
friend ostream& operator << (ostream &out, const plant &p);
};

#endif /* plant_h*/

plant.cpp

#include "plant.h"
plant::plant()
{
growth = 0;
water = 0;
nutrition = 0;
id = "";
}
plant::plant(string id, int growth, int nutrition, int water)
{
this->id = id;
this->growth = growth;
this->nutrition = nutrition;
this->water = water;
}

//copy constructor
plant::plant(const plant &p)
{
this->id = p.id;
this->growth = p.growth;
this->nutrition = p.nutrition;
this->water = p.water;
}

string plant::getId() const
{
return id;
}
int plant::getGrowth() const
{
return growth;
}
int plant::getNutrition() const
{
return nutrition;
}
int plant::getWater() const
{
return water;
}
void plant::setId(string id)
{
this->id = id;
}
void plant::setGrowth(int g)
{
this->growth = g;
}
void plant::setNutrition(int n)
{
this->nutrition = n;
}
void plant::setWater(int w)
{
this->water = w;
}
ostream& operator << (ostream &out, const plant &p)
{
out << "Plant ID: Plant " << p.growth << "-" << p.nutrition << "-" << p.water;
out << "(G: " << p.growth << " N:" << p.nutrition << " W:" << p.water << ")" << endl;
return out;
}

planttree.h

#ifndef planttree_h
#define planttree_h
#include "plant.h"
#include <iostream>

class treenode
{
public:
plant* plantData;
treenode *left;
treenode *right;
treenode(plant *p)
{
plantData = p;
left = right = nullptr;
}
treenode(const treenode &tn)
{
plantData = new plant(*tn.plantData);
if(tn.left != nullptr)
left = new treenode(*tn.left);
else
left = nullptr;
if(tn.right != nullptr)
right = new treenode(*tn.right);
else
right = nullptr;
}
  
};
class planttree
{
treenode *root;
void deleteTree(treenode *p);
void display(treenode *p);
treenode* find(treenode *parent, const plant &search);
plant* findBestGrowth(treenode *p);
plant* findBestNutrition(treenode *p);
plant* findBestWater(treenode *p);
public:
planttree();
planttree(const planttree &pt);
void setRoot(const plant &p);
void addChildren(const plant &parent, const plant &left, const plant &right);
void display();
plant* findBestGrowth();
plant* findBestNutrition();
plant* findBestWater();
~planttree();
};
#endif /* planttree_h */

planttree.cpp

#include "planttree.h"
planttree::planttree()
{
root = nullptr;
}
planttree::planttree(const planttree &pt)
{
if(pt.root != nullptr)
root = new treenode(*pt.root);
else
root = nullptr;
}

void planttree::setRoot(const plant &p)
{
root = new treenode(new plant(p));
}

void planttree::addChildren(const plant &parent, const plant &left, const plant &right)
{
treenode *p = find(root, parent);
if(p != nullptr)
{
p->left = new treenode(new plant(left));
p->right = new treenode(new plant(right));
}
}

treenode* planttree::find(treenode *parent, const plant &search)
{
if(parent == nullptr)
return nullptr;
else
{
if(parent->plantData->getId() == search.getId())
return parent;
else
{
treenode *p = find(parent->left, search);
if(p == nullptr)
return find(parent->right, search);
else
return p;
}
}
}

void planttree::display()
{
display(root);
}
void planttree::display(treenode *p)
{
if(p != nullptr)
{
cout << *p->plantData;
display(p->left);
display(p->right);
}
}
void planttree::deleteTree(treenode *p)
{
if(p == nullptr)return;
deleteTree(p->left);
deleteTree(p->right);
delete p->plantData;
delete p;
}

plant* planttree::findBestGrowth()
{
return findBestGrowth(root);
}
plant* planttree::findBestNutrition()
{
return findBestNutrition(root);
}

plant* planttree::findBestWater()
{
return findBestWater(root);
}

plant* planttree::findBestGrowth(treenode *p)
{
plant *max = nullptr;
  
if(p != nullptr)
{
max = p->plantData;
plant *lmax = findBestGrowth(p->left);
plant *rmax = findBestGrowth(p->right);
if(lmax != nullptr && lmax->getGrowth() > max->getGrowth())
max = lmax;
  
if(rmax != nullptr && rmax->getGrowth() > max->getGrowth())
max = rmax;
  
}
return max;
}
plant* planttree::findBestNutrition(treenode *p)
{
plant *max = nullptr;
  
if(p != nullptr)
{
max = p->plantData;
plant *lmax = findBestNutrition(p->left);
plant *rmax = findBestNutrition(p->right);
if(lmax != nullptr && lmax->getNutrition() > max->getNutrition())
max = lmax;
  
if(rmax != nullptr && rmax->getNutrition() > max->getNutrition())
max = rmax;
}
return max;
  
}
plant* planttree::findBestWater(treenode *p)
{
plant *max = nullptr;
  
if(p != nullptr)
{
max = p->plantData;
plant *lmax = findBestWater(p->left);
plant *rmax = findBestWater(p->right);
if(lmax != nullptr && lmax->getWater() > max->getWater())
max = lmax;
  
if(rmax != nullptr && rmax->getWater() > max->getWater())
max = rmax;
}
return max;
}
planttree::~planttree()
{
deleteTree(root);
}

***************************************************************************************
Sample Output:

output of experiments.cpp

===================================
Experiment 1
===================================
Plant ID: Plant 1-1-1(G: 1 N:1 W:1)
Plant ID: Plant 66-91-36(G: 66 N:91 W:36)
Plant ID: Plant 99-39-21(G: 99 N:39 W:21)
Plant ID: Plant 86-95-56(G: 86 N:95 W:56)
Plant ID: Plant 19-79-59(G: 19 N:79 W:59)
Plant ID: Plant 34-95-96(G: 34 N:95 W:96)
Plant ID: Plant 54-62-28(G: 54 N:62 W:28)
Plant ID: Plant 10-18-32(G: 10 N:18 W:32)
Plant ID: Plant 33-15-93(G: 33 N:15 W:93)
Plant ID: Plant 58-20-32(G: 58 N:20 W:32)
Plant ID: Plant 26-18-28(G: 26 N:18 W:28)
Plant ID: Plant 41-15-65(G: 41 N:15 W:65)
Plant ID: Plant 26-21-28(G: 26 N:21 W:28)
Plant ID: Plant 90-42-4(G: 90 N:42 W:4)
Plant ID: Plant 90-20-32(G: 90 N:20 W:32)
Plant ID: Plant 47-21-93(G: 47 N:21 W:93)
Plant ID: Plant 62-32-32(G: 62 N:32 W:32)
Plant ID: Plant 10-30-88(G: 10 N:30 W:88)
Plant ID: Plant 33-71-75(G: 33 N:71 W:75)
Plant ID: Plant 82-99-88(G: 82 N:99 W:88)
Plant ID: Plant 15-95-75(G: 15 N:95 W:75)
Plant ID: Plant 38-2-8(G: 38 N:2 W:8)
Plant ID: Plant 26-50-64(G: 26 N:50 W:64)
Plant ID: Plant 41-29-51(G: 41 N:29 W:51)
Plant ID: Plant 90-28-88(G: 90 N:28 W:88)
Plant ID: Plant 58-12-8(G: 58 N:12 W:8)
Plant ID: Plant 43-93-45(G: 43 N:93 W:45)
Plant ID: Plant 82-85-8(G: 82 N:85 W:8)
Plant ID: Plant 66-30-16(G: 66 N:30 W:16)
Plant ID: Plant 74-0-12(G: 74 N:0 W:12)
Plant ID: Plant 11-21-93(G: 11 N:21 W:93)
Plant ID: Plant 26-72-72(G: 26 N:72 W:72)
Plant ID: Plant 90-30-48(G: 90 N:30 W:48)
Plant ID: Plant 47-71-15(G: 47 N:71 W:15)
Plant ID: Plant 50-99-72(G: 50 N:99 W:72)
Plant ID: Plant 7-95-7(G: 7 N:95 W:7)
Plant ID: Plant 10-79-68(G: 10 N:79 W:68)
Plant ID: Plant 62-18-32(G: 62 N:18 W:32)
Plant ID: Plant 2-2-48(G: 2 N:2 W:48)
Plant ID: Plant 5-3-15(G: 5 N:3 W:15)
Plant ID: Plant 82-80-52(G: 82 N:80 W:52)
Plant ID: Plant 2-50-96(G: 2 N:50 W:96)
Plant ID: Plant 5-29-19(G: 5 N:29 W:19)
Plant ID: Plant 38-55-44(G: 38 N:55 W:44)
Plant ID: Plant 78-38-52(G: 78 N:38 W:52)
Plant ID: Plant 82-28-72(G: 82 N:28 W:72)
Plant ID: Plant 15-45-7(G: 15 N:45 W:7)
Plant ID: Plant 38-80-48(G: 38 N:80 W:48)
Plant ID: Plant 62-12-52(G: 62 N:12 W:52)
Plant ID: Plant 35-93-7(G: 35 N:93 W:7)
Plant ID: Plant 58-85-68(G: 58 N:85 W:68)
Plant ID: Plant 43-29-95(G: 43 N:29 W:95)
Plant ID: Plant 74-98-28(G: 74 N:98 W:28)
Plant ID: Plant 58-30-32(G: 58 N:30 W:32)
Plant ID: Plant 43-71-93(G: 43 N:71 W:93)
Plant ID: Plant 74-12-32(G: 74 N:12 W:32)
Plant ID: Plant 58-0-8(G: 58 N:0 W:8)
Plant ID: Plant 43-21-45(G: 43 N:21 W:45)
Plant ID: Plant 82-51-8(G: 82 N:51 W:8)
Plant ID: Plant 66-50-16(G: 66 N:50 W:16)
Plant ID: Plant 74-72-12(G: 74 N:72 W:12)
Plant ID: Plant 11-67-93(G: 11 N:67 W:93)
Plant ID: Plant 26-80-72(G: 26 N:80 W:72)

Best growth rate:
Plant ID: Plant 99-39-21(G: 99 N:39 W:21)

Best nutritional value:
Plant ID: Plant 82-99-88(G: 82 N:99 W:88)

Best water requirement:
Plant ID: Plant 34-95-96(G: 34 N:95 W:96)

===================================
Experiment 2
===================================
Plant ID: Plant 11-17-33(G: 11 N:17 W:33)
Plant ID: Plant 6-63-20(G: 6 N:63 W:20)
Plant ID: Plant 61-75-17(G: 61 N:75 W:17)
Plant ID: Plant 94-79-68(G: 94 N:79 W:68)
Plant ID: Plant 91-95-95(G: 91 N:95 W:95)
Plant ID: Plant 74-79-8(G: 74 N:79 W:8)
Plant ID: Plant 10-18-84(G: 10 N:18 W:84)
Plant ID: Plant 46-62-28(G: 46 N:62 W:28)
Plant ID: Plant 21-57-65(G: 21 N:57 W:65)
Plant ID: Plant 90-0-32(G: 90 N:0 W:32)
Plant ID: Plant 10-78-12(G: 10 N:78 W:12)
Plant ID: Plant 33-5-93(G: 33 N:5 W:93)
Plant ID: Plant 82-71-20(G: 82 N:71 W:20)
Plant ID: Plant 26-62-28(G: 26 N:62 W:28)
Plant ID: Plant 58-20-72(G: 58 N:20 W:72)
Plant ID: Plant 43-21-7(G: 43 N:21 W:7)
Plant ID: Plant 74-32-48(G: 74 N:32 W:48)
Plant ID: Plant 90-10-16(G: 90 N:10 W:16)
Plant ID: Plant 47-71-1(G: 47 N:71 W:1)
Plant ID: Plant 50-99-36(G: 50 N:99 W:36)
Plant ID: Plant 7-95-21(G: 7 N:95 W:21)
Plant ID: Plant 2-2-88(G: 2 N:2 W:88)
Plant ID: Plant 2-50-48(G: 2 N:50 W:48)
Plant ID: Plant 5-29-15(G: 5 N:29 W:15)
Plant ID: Plant 82-28-52(G: 82 N:28 W:52)
Plant ID: Plant 62-52-8(G: 62 N:52 W:8)
Plant ID: Plant 35-47-45(G: 35 N:47 W:45)
Plant ID: Plant 58-67-8(G: 58 N:67 W:8)
Plant ID: Plant 58-70-16(G: 58 N:70 W:16)
Plant ID: Plant 58-20-12(G: 58 N:20 W:12)
Plant ID: Plant 43-21-93(G: 43 N:21 W:93)
Plant ID: Plant 74-32-72(G: 74 N:32 W:72)
Plant ID: Plant 90-10-12(G: 90 N:10 W:12)
Plant ID: Plant 47-71-93(G: 47 N:71 W:93)
Plant ID: Plant 50-99-20(G: 50 N:99 W:20)
Plant ID: Plant 7-95-17(G: 7 N:95 W:17)
Plant ID: Plant 10-79-68(G: 10 N:79 W:68)
Plant ID: Plant 62-18-12(G: 62 N:18 W:12)
Plant ID: Plant 2-2-16(G: 2 N:2 W:16)
Plant ID: Plant 5-3-1(G: 5 N:3 W:1)
Plant ID: Plant 82-80-8(G: 82 N:80 W:8)
Plant ID: Plant 2-50-28(G: 2 N:50 W:28)
Plant ID: Plant 5-29-65(G: 5 N:29 W:65)
Plant ID: Plant 38-55-28(G: 38 N:55 W:28)
Plant ID: Plant 78-38-4(G: 78 N:38 W:4)
Plant ID: Plant 82-28-32(G: 82 N:28 W:32)
Plant ID: Plant 15-45-93(G: 15 N:45 W:93)
Plant ID: Plant 38-80-32(G: 38 N:80 W:32)
Plant ID: Plant 62-52-72(G: 62 N:52 W:72)
Plant ID: Plant 35-47-7(G: 35 N:47 W:7)
Plant ID: Plant 58-67-68(G: 58 N:67 W:68)
Plant ID: Plant 43-87-95(G: 43 N:87 W:95)
Plant ID: Plant 74-90-28(G: 74 N:90 W:28)
Plant ID: Plant 58-70-32(G: 58 N:70 W:32)
Plant ID: Plant 43-29-93(G: 43 N:29 W:93)
Plant ID: Plant 74-68-32(G: 74 N:68 W:32)
Plant ID: Plant 58-20-48(G: 58 N:20 W:48)
Plant ID: Plant 43-21-15(G: 43 N:21 W:15)
Plant ID: Plant 82-51-72(G: 82 N:51 W:72)
Plant ID: Plant 66-50-96(G: 66 N:50 W:96)
Plant ID: Plant 74-32-52(G: 74 N:32 W:52)
Plant ID: Plant 11-73-7(G: 11 N:73 W:7)
Plant ID: Plant 26-40-8(G: 26 N:40 W:8)

Best growth rate:
Plant ID: Plant 94-79-68(G: 94 N:79 W:68)

Best nutritional value:
Plant ID: Plant 50-99-36(G: 50 N:99 W:36)

Best water requirement:
Plant ID: Plant 66-50-96(G: 66 N:50 W:96)

Add a comment
Know the answer?
Add Answer to:
%%%%% c++ assignment %%%%%% ///////// please test your program and check for errors. //////// you should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Object Oriented assignment Can you please check the program written below if it has appropriately...

    C++ Object Oriented assignment Can you please check the program written below if it has appropriately fulfilled the instructions provided below. Please do the necessary change that this program may need. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given. INSTRUCTIONS Create a fraction class and add your Name to the name fraction and use this...

  • Please help fix my code C++, I get 2 errors when running. The code should be...

    Please help fix my code C++, I get 2 errors when running. The code should be able to open this file: labdata.txt Pallet PAG PAG45982IB 737 4978 OAK Container AYF AYF23409AA 737 2209 LAS Container AAA AAA89023DL 737 5932 DFW Here is my code: #include <iostream> #include <string> #include <fstream> #include <vector> #include <cstdlib> #include <iomanip> using namespace std; const int MAXLOAD737 = 46000; const int MAXLOAD767 = 116000; class Cargo { protected: string uldtype; string abbreviation; string uldid; int...

  • == Programming Assignment == For this assignment you will write a program that controls a set...

    == Programming Assignment == For this assignment you will write a program that controls a set of rovers and sends them commands to navigate on the Martian surface where they take samples. Each rover performs several missions and each mission follows the same sequence: deploy, perform one or more moves and scans, then return to base and report the results. While on a mission each rover needs to remember the scan results, in the same order as they were taken,...

  • Assignment #1: Write a C++ Program. Consider the following program segment. // Name: Your Name //...

    Assignment #1: Write a C++ Program. Consider the following program segment. // Name: Your Name // MU ID: Your ID // include statement (s) l using namespace statement int main() //variable declaration //executable statements // return statement a. Include the header files isotream. b. Include cin, cout, and endl. c. Declare two variables: numi, num2, num3, and average of type int. d. Assign 125 into numi, 28 into num2, and -25 into num3 e. Store the average of numi, num2,...

  • in c++ please program for this code #include <iostream> #include <fstream> #include <string> #include <cstring> //...

    in c++ please program for this code #include <iostream> #include <fstream> #include <string> #include <cstring> // for string tokenizer and c-style string processing #include <algorithm> // max function #include <stdlib.h> #include <time.h> using namespace std; // Extend the code here as needed class BTNode{ private: int nodeid; int data; int levelNum; BTNode* leftChildPtr; BTNode* rightChildPtr; public: BTNode(){} void setNodeId(int id){ nodeid = id; } int getNodeId(){ return nodeid; } void setData(int d){ data = d; } int getData(){ return data;...

  • C++ EXERCISE (DATA STRUCTURES). I just need a code for some functions that are missing. Please...

    C++ EXERCISE (DATA STRUCTURES). I just need a code for some functions that are missing. Please help me figure out. Thanks. C++ BST implementation (using a struct) Enter the code below, and then compile and run the program. After the program runs successfully, add the following functions: postorder() This function is similar to the inorder() and preorder() functions, but demonstrates postorder tree traversal. displayParentsWithTwo() This function is similar to the displayParents WithOne() function, but displays nodes having only two children....

  • C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you...

    C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you can. Level 1: (20 points) Write FUNCTIONS for each of the following: a) Validate #students, #scores. b) Compute letter grade based on average. c) Display student letter grade. d) Display course average. Level 2: (15 points) Use ARRAYS for each of the following. e) Read a student's scores into array. f) Calculate the student's average based on scores in array. g) Display the student's...

  • == Programming Assignment == For this assignment you will write a program that reads in the...

    == Programming Assignment == For this assignment you will write a program that reads in the family data for the Martian colonies and stores that data in an accessible database. This database allows for a user to look up a family and its immediate friends. The program should store the data in a hashtable to ensure quick access time. The objective of this assignment is to learn how to implement and use a hashtable. Since this is the objective, you...

  • okay so here is my c++ code and the errors im really stuck on fixing what...

    okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...

  • Right now, program pushes all data to screen in three loops need to prompt user for...

    Right now, program pushes all data to screen in three loops need to prompt user for three text files, and need to push data from each loop into those three text files. #include #include #include #include #include #include #include #include using namespace std; double random(double minprice, double maxprice); string printRandomString(int n); bool coinToss(); int clicks(); int runme(); int createfiles(); struct things{     //things();     int id;     string name;     string category;     double price;     bool two_day_shipping;     int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT