Help finding my errors in C++ please
Header file
#ifndef _FISH_SHOWER_H
#define _FISH_SHOWER_H
#include <iostream>
#include <string>
using namespace std;
//NOTE: Prototypes are correct, use as a guide
void WriteHeader();
void FillVectors(vector<string> &type, vector<int>
&minGals, vector<int> &maxGallons);
void AskFishShowerTypes(vector<string> &type, int
*pIndex);
void CalcPondVol(int *pGal);
bool ValidateFishShower(int index, int pondVol, vector<int>
&minGals, vector<int> &maxGals, vector<int>
&rec);
void WriteInfo(string showerType, int gallons);
void WriteInfo(string showerType, vector<string>
&showerTypes, vector<int> &recommendations, int
gallons);
#endif
Main file
#include "FishShower.h"
using namespace std;
int main()
{
string type = "", goAgain;
int gallons, index;
bool bValid;
vector<string> showerTypes;
vector<int> minRange;
vector<int> maxRange;
vector<int> recommendations;
FillVectors(showerTypes, minRange, maxRange);
WriteHeader();
do
{
AskFishShowerTypes(showerTypes,
&index);
CalcPondVol(&gallons);
bValid =
ValidateFishShower(gallons, index, minRange, maxRange,
recommendations);
if(!bValid)
{
WriteInfo(showerTypes.at(index), gallons);
}
else
{
WriteInfo(showerTypes.at(index), showerTypes, recommendations,
gallons);
}
cout << "\n\nWant to enter
another? yes/no ";
cin >> goAgain;
cin.ignore();
recommendations.clear();
}while(goAgain = "yes");
cout << "\n\nThanks for playing!\n" << endl;
cin.get();
return 0;
}
Functions file
void WriteHeader()
{
cout << "Student Debugger Q5\n"
<< "\nThis program gathers
info concerning the user's"
<< "\npond and choice of C++
Fish Showers."
<< "\nIt makes suggestions
for a perfect Fish Shower."
<< "\n\nProgram: Fish
Shower\n" << endl;
}
void FillVectors(vector<string> &types,
vector<int> &minGals, vector<int> maxGallons)
{
types.push_back("Shebunkin Sprayer");
types.push_back("Koi Rain Head");
types.push_back("Golden Orfie Wash");
types.push_back("Goldfish Rain Storm");
types.push_back("Comet Monsoon");
minGals.push_back(200);
minGals.push_back(300);
minGals.push_back(400);
minGals.push_back(900);
minGals.push_back(5000);
maxGallons.push_back(400);
maxGallons.push_back(500);
maxGallons.push_back(1000);
maxGallons.push_back(5000);
maxGallons.push_back(10000);
}
void AskFishShowerTypes(vector<string> &showerTypes,
int *pIndex)
{
cout << "\n\n Here are the five types of showers
offered:";
for (unsigned int i = 0; i < showerTypes.size();
++i)
{
cout << "\n" << i + 1
<< ". " << showerTypes.at(i);
}
cout << "\n\n Please enter the number of the
shower you are interested in: ";
cin >> *pIndex;
*pIndex = *pIndex - 1; //now zero-indexed
cin.ignore();
}
void CalcPondVol(int *pGallons)
{
const double PI = 3.14159265;
const double CUBIC_INCHES_PER_GALLON = 231.0;
int num;
cout << "\n Now we'll estimate the volume of
your pond. ";
cout << "\n Is your pond 1) Circular or 2)
Rectangular ? ";
cin >> num;
cin.ignore();
double diameter, depth, length, width, gallons, cubicInchVol;
cout << "\n How deep is your pond in inches:
";
cin >> depth;
cin.ignore();
if(num == 1) //circular
{
cout << "\n Please enter the
pond's diameter in inches: ";
cin >> diameter;
cin.ignore();
double radius =
diameter/2.0;
//use cylinder formula for volume
Pi*r*r*h
cubicInchVol = PI * radius * radius
*depth;
}
else if(num == 2) //rectangular
{
cout << "\n Please enter the
pond's length and width in inches: ";
cin >> length >>
width;
cin.ignore();
//use box formula for volume
length * width * depth
cubicInchVol = length * width *
depth;
}
else
{
cout << "\n You entered an
invalid number. Please try again.";
}
gallons =
cubicInchVol/CUBIC_INCHES_PER_GALLON;
pGallons =
static_cast<int>(ceil(gallons));
}
bool ValidateFishShower(int index, int pondVol,
vector<int> &minGals, vector<int> &maxGals,
vector<int> &recommends)
{
const int MIN_VOLUME = 200; //gallons
const int MAX_VOLUME = 10000; //gallons
//check that there is a Fish Shower that will
work
if(pondVol > MAX_VOLUME && pondVol <
MIN_VOLUME)
{
return false;
}
//check if the pond valume is within the range of the
selected FishShower
else if(pondVol >= minGals.at(index) &&
pondVol <= maxGals.at(index))
{
return true;
}
else
{
//check the other ranges for a
recommendation
//check all of the ranges and fill
another vector with matches
for(int i = 0; i < 5; ++i)
{
if(i !=
index)
{
if(pondVol>= minGals.at(i) && pondVol
<= maxGals.at(i))
{
recommends.push_back(i);
}
}
}
return false;
}
}
void WriteInfo(string showerType, int gallons)
{
cout<<"\n\n Good choice! For a " <<
gallons << " gallon pond"
<<"\n you selected a
"<< showerType << " Fish Shower!";
}
void WriteInfo(string showerType, vector<string>
&showerTypes, vector<int> &recommendations, int
gallons)
{
if(recommendations.empty())
{
cout<< "\n\n The size of your
pond, "<<*gallons<<" gallons, is outside of the ranges
for the Fish Showers.";
}
else
{
cout<<"\n\n Sorry, the
"<< showerType << " is not appropriate for your
"<< gallons << " gallon pond."
<<"\n May
we suggest:";
for( unsigned int i = 0; i<
recommendations.size(); ++i)
{
int index =
recommendations.at(i);
cout <<"\n
"<< showerTypes.at(index);
}
}
}
/* FishShower.h */
#ifndef _FISH_SHOWER_H
#define _FISH_SHOWER_H
#include <iostream>
#include <string>
#include<vector> // error forget to add
using namespace std;
//NOTE: Prototypes are correct, use as a guide
void WriteHeader();
void FillVectors(vector<string> &type, vector<int>
&minGals, vector<int> &maxGallons);
void AskFishShowerTypes(vector<string> &type, int
*pIndex);
void CalcPondVol(int *pGal);
bool ValidateFishShower(int index, int pondVol, vector<int>
&minGals, vector<int> &maxGals, vector<int>
&rec);
void WriteInfo(string showerType, int gallons);
void WriteInfo(string showerType, vector<string>
&showerTypes, vector<int> &recommendations, int
gallons);
#endif
/* main.cpp */
#include "FishShower.h"
#include<math.h>
#include<vector>
using namespace std;
int main()
{
string type = "", goAgain;
int gallons, index;
bool bValid;
vector<string> showerTypes;
vector<int> minRange;
vector<int> maxRange;
vector<int> recommendations;
FillVectors(showerTypes, minRange, maxRange);
WriteHeader();
do
{
AskFishShowerTypes(showerTypes, &index);
CalcPondVol(&gallons);
bValid = ValidateFishShower(gallons, index, minRange, maxRange,
recommendations);
if(!bValid)
{
WriteInfo(showerTypes.at(index), gallons);
}
else
{
WriteInfo(showerTypes.at(index), showerTypes, recommendations,
gallons);
}
cout << "\n\nWant to enter another? yes/no
";
cin >> goAgain;
cin.ignore();
recommendations.clear();
}while(goAgain == "yes"); // error == instead of =
cout << "\n\nThanks for playing!\n" << endl;
cin.get();
return 0;
}
//Functions file error there were no comments earlier
void WriteHeader()
{
cout << "Student Debugger Q5\n"
<< "\nThis program gathers info concerning the user's"
<< "\npond and choice of C++ Fish Showers."
<< "\nIt makes suggestions for a perfect Fish Shower."
<< "\n\nProgram: Fish Shower\n" << endl;
}
// Error vector<int> &maxGallons & missing
void FillVectors(vector<string> &types, vector<int>
&minGals, vector<int> &maxGallons)
{
types.push_back("Shebunkin Sprayer");
types.push_back("Koi Rain Head");
types.push_back("Golden Orfie Wash");
types.push_back("Goldfish Rain Storm");
types.push_back("Comet Monsoon");
minGals.push_back(200);
minGals.push_back(300);
minGals.push_back(400);
minGals.push_back(900);
minGals.push_back(5000);
maxGallons.push_back(400);
maxGallons.push_back(500);
maxGallons.push_back(1000);
maxGallons.push_back(5000);
maxGallons.push_back(10000);
}
void AskFishShowerTypes(vector<string>
&showerTypes, int *pIndex)
{
cout << "\n\n Here are the five types of showers
offered:";
for (unsigned int i = 0; i < showerTypes.size(); ++i)
{
cout << "\n" << i + 1 << ". " <<
showerTypes.at(i);
}
cout << "\n\n Please enter the number of the
shower you are interested in: ";
cin >> *pIndex;
*pIndex = *pIndex - 1; //now zero-indexed
cin.ignore();
}
void CalcPondVol(int *pGallons)
{
const double PI = 3.14159265;
const double CUBIC_INCHES_PER_GALLON = 231.0;
int num;
cout << "\n Now we'll estimate the volume of your pond.
";
cout << "\n Is your pond 1) Circular or 2) Rectangular ?
";
cin >> num;
cin.ignore();
double diameter, depth, length, width, gallons, cubicInchVol;
cout << "\n How deep is your pond in inches:
";
cin >> depth;
cin.ignore();
if(num == 1) //circular
{
cout << "\n Please enter the pond's diameter in inches:
";
cin >> diameter;
cin.ignore();
double radius = diameter/2.0;
//use cylinder formula for volume Pi*r*r*h
cubicInchVol = PI * radius * radius *depth;
}
else if(num == 2) //rectangular
{
cout << "\n Please enter the pond's length and width in
inches: ";
cin >> length >> width;
cin.ignore();
//use box formula for volume length * width *
depth
cubicInchVol = length * width * depth;
}
else
{
cout << "\n You entered an invalid number. Please try
again.";
}
gallons = cubicInchVol/CUBIC_INCHES_PER_GALLON;
*pGallons = static_cast<int>(ceil(gallons)); // *pgallons
since pointer
}
bool ValidateFishShower(int index, int pondVol,
vector<int> &minGals, vector<int> &maxGals,
vector<int> &recommends)
{
const int MIN_VOLUME = 200; //gallons
const int MAX_VOLUME = 10000; //gallons
//check that there is a Fish Shower that will work
if(pondVol > MAX_VOLUME && pondVol <
MIN_VOLUME)
{
return false;
}
//check if the pond valume is within the range of the selected
FishShower
else if(pondVol >= minGals.at(index) && pondVol <=
maxGals.at(index))
{
return true;
}
else
{
//check the other ranges for a recommendation
//check all of the ranges and fill another vector with
matches
for(int i = 0; i < 5; ++i)
{
if(i != index)
{
if(pondVol>= minGals.at(i) && pondVol <=
maxGals.at(i))
{
recommends.push_back(i);
}
}
}
return false;
}
}
void WriteInfo(string showerType, int gallons)
{
cout<<"\n\n Good choice! For a " << gallons << "
gallon pond"
<<"\n you selected a "<< showerType << " Fish
Shower!";
}
void WriteInfo(string showerType, vector<string>
&showerTypes, vector<int> &recommendations, int
gallons)
{
if(recommendations.empty())
{
cout<< "\n\n The size of your pond, "<<gallons<<"
gallons, is outside of the ranges for the Fish Showers.";
}
else
{
cout<<"\n\n Sorry, the "<< showerType << " is not
appropriate for your "<< gallons << " gallon
pond."
<<"\n May we suggest:";
for( unsigned int i = 0; i< recommendations.size(); ++i)
{
int index = recommendations.at(i);
cout <<"\n "<< showerTypes.at(index);
}
}
}
/* OUTPUT */
Student Debugger Q5
This program gathers info concerning the user's
pond and choice of C++ Fish Showers.
It makes suggestions for a perfect Fish Shower.
Program: Fish Shower
Here are the five types of showers offered:
1. Shebunkin Sprayer
2. Koi Rain Head
3. Golden Orfie Wash
4. Goldfish Rain Storm
5. Comet Monsoon
Please enter the number of the shower you are interested in: 1
Now we'll estimate the volume of your pond.
Is your pond 1) Circular or 2) Rectangular ? 1
How deep is your pond in inches: 2
Please enter the pond's diameter in inches: 5
Good choice! For a 1 gallon pond
you selected a Shebunkin Sprayer Fish Shower!
Want to enter another? yes/no no
Thanks for playing!
/* PLEASE UPVOTE */
Help finding my errors in C++ please Header file #ifndef _FISH_SHOWER_H #define _FISH_SHOWER_H #include <iostream> #include...
Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...
vector.h: #ifndef VECTOR_H #define VECTOR_H #include <algorithm> #include <iostream> #include <cassert> template <typename T> class Vector { public: Vector( int initsize = 0 ) : theSize( initsize ), theCapacity( initsize + SPARE_CAPACITY ) { objects = new T[ theCapacity ]; } Vector( const Vector & rhs ) : theSize( rhs.theSize), theCapacity( rhs.theCapacity ), objects( 0 ) { objects = new T[ theCapacity ]; for( int k = 0; k < theSize; ++k) objects[ k ] = rhs.objects[ k...
In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...
my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...
I need help with those two functions c++ #ifndef TRIPLE_H #define TRIPLE_H #include <iostream> #include <string> using namespace std; class Triple { private: int a, b, c; public: Triple(); // all elements have value 0 Triple(int k); // all elements have value k Triple(int x, int y, int z); // specifies all three elements Triple(string s); // string representation is "(a,b,c)" string toString(); // create a string representation of the vector void fromString(string s); // change the vector to equal...
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...
I keep getting errors and i am so confused can someone please help and show the input and output ive tried so many times cant seem to get it.
main.cpp
#include <iostream>
#include <vector>
#include <string>
#include "functions.h"
int main()
{
char option;
vector<movie> movies;
while (true)
{
printMenu();
cin >>
option;
cin.ignore();
switch (option)
{
case 'A':
{
string nm;
int year;
string genre;
cout << "Movie Name: ";
getline(cin, nm);
cout << "Year: ";
cin >> year;
cout << "Genre: ";
cin >> genre;
//call you addMovie() here
addMovie(nm, year, genre, &movies);
cout << "Added " << nm << " to the catalog"
<< endl;
break;
}
case 'R':
{
string mn;
cout << "Movie Name:";
getline(cin, mn);
bool found;
//call you removeMovie() here
found = removeMovie(mn, &movies);
if (found == false)
cout << "Cannot find " << mn << endl;
else
cout << "Removed " << mn << " from catalog"
<< endl;
break;
}
case 'O':
{
string mn;
cout << "Movie Name: ";
getline(cin, mn);
cout << endl;
//call you movieInfo function here
movieInfo(mn, movies);
break;
}
case 'C':
{
cout << "There are " << movies.size() << " movies
in the catalog" << endl;
// Call the printCatalog function here
printCatalog(movies);
break;
}
case 'F':
{
string inputFile;
bool isOpen;
cin >> inputFile;
cout << "Reading catalog info from " << inputFile
<< endl;
//call you readFromFile() in here
isOpen = readFile(inputFile, &movies);
if (isOpen == false)
cout << "File not found" << endl;...
c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...
Need help with the trickle down This is the maxheap.h #ifndef MAXHEAP_H_INCLUDED #define MAXHEAP_H_INCLUDED #include <vector> #include <sstream> #include <string> #include <queue> #include <cmath> // pow() using namespace std; #define PARENT(i) ((i-1) / 2) #define LINE_WIDTH 60.0 template<class T> class MaxHeap{ // private: vector<T> heap; void bubbleUp(int id); void Heapify() { int length = heap.size(); for(int i=length / 2 -1; i>=0; --i) trickleDown(i); }; public: MaxHeap( vector<T> &vector ) : heap(vector) { Heapify(); } ; MaxHeap() {}; void trickleDown(int...