Hello I have to create a program which allows the user to enter the type, number, size and aggression of how ever many types of fish they have and then calculate how large of a fish tank they would need. The problem I am having is when the user enters another type of fish, the program works fine if they have one type of fish. The only way I can think of to let them enter a new type of fish type, number, size and aggression is to re write the whole code with different variables.
This is what I have so far any advice would be greatly appreciated.
#include <iostream> // for cout and cin
#include <string>
#include <vector>
#include <iomanip>
usingnamespace std;
int main()
{
cout << " Christian Seely"
<< "\n Project 3"
<< "\n The objective of this project is to find the user a fish tank that is in stock,"
<< " based on the number, type, size and agression of the fish.";
string answer1;
int GallonsOfWater;
while (answer1 == "yes" || answer1 == "Yes" || answer1 == "y" || answer1 == "Y");
{
vector<string>VFish;
VFish.push_back("Neon Tetras");
VFish.push_back("Clown Loaches");
VFish.push_back("Betta Fish");
VFish.push_back("Koi Angel");
VFish.push_back("Checkerboard Discus");
cout << " \n\nPlease enter the numeric value which corresponds with the type of fish you wish to purchase.";
for (int i = 0; i < VFish.size(); ++i)
cout << "\n" << i + 1 << setw(20) << VFish.at(i);
cout << " \nType of fish: ";
int TypeOfFish;
cin >> TypeOfFish;
cin.ignore();
cout << " \n\n Please enter the number of the type of fish selected."
<< "\n Number: ";
int input = 0;
int input2 = 0;
vector<int>VNumberOfFish;
cin >> input;
cin.ignore();
VNumberOfFish.push_back(input);
cout << "\n\nPlease enter the numeric value in half inch increments of the size of fish"
<< "\n that you are purchasing, range of the size is from .5 inches to 6 inches."
<< "\n Size of fish: ";
int SizeOfFish = 0;
vector<double>VFishSize;
cin >> SizeOfFish;
cin.ignore();
VFishSize.push_back(SizeOfFish);
cout << "\n Are your fish agressive?"
<< "\n Please enter a 'Y' for yes or a 'N' for no: ";
string aggression;
getline(cin,aggression);
if ( aggression == "yes" || aggression == "Yes" || aggression == "Y" || aggression == "y")
{
GallonsOfWater = (SizeOfFish * 3 * input);
cout << GallonsOfWater;
}
if ( aggression != "yes" || aggression != "Yes" || aggression != "Y" || aggression != "y")
{
GallonsOfWater = (SizeOfFish * 2 * input);
}
cout << "\n\nWould you like to select another type of fish? ";
getline(cin,answer1);
if (answer1 == "no" || answer1 == "No" || answer1 == "n" || answer1 == "N")
{
string TypeOfTheFish;
int index = 0;
cout << "\n\n Type of Fish Number Adult Size (in inches)\n\n";
cout <<" "<< VFish.at(TypeOfFish -1);
cout << " "<<input<<" "<< SizeOfFish << "\n\n";
cout << "\n\n Aggressive: " <<aggression;
cout << "\n Total Fish Length: " <<SizeOfFish;
cout << "\n Minimum Required Gallons: " << GallonsOfWater;
cout << "\n Min Tank Size: ";
if (GallonsOfWater <= 80)
{
if ( GallonsOfWater >= 1 && GallonsOfWater <= 20 )
{
int SizeOfTank = 20;
cout << " 20 gallons\n\n";
}
if ( GallonsOfWater >= 21 && GallonsOfWater <= 40)
{
int SizeOfTank = 40;
cout << " 40 gallons\n\n";
}
if ( GallonsOfWater >=41 && GallonsOfWater <=60)
{
int SizeOfTank= 60;
cout << " 60 gallons\n\n";
}
if ( GallonsOfWater >=61 && GallonsOfWater <=80)
{
int SizeOfTank = 80;
cout << " 80 gallons\n\n";
}
}
}
else
{
cout << "\n We do not carry a tank large enough for that";
}
}
return 0;
}