#include #include #include #include using namespace std; struct Cost { double hours; double cost; double costFood; double costSupplies; }; struct Creatures { char name[50]; char description[200]; double length; double height; char location[100]; bool dangerous; Cost management; }; int enterCreatures(int, Creatures[]); void printCreatures(int, Creatures[]); void printStatistics(int, Creatures[]); void saveCreaturesToFile(int, Creatures[]); float convertToFloat(string); const int SIZE = 100; int main() { Creatures profile[SIZE]; int menuChoice, currentNumber; char menuChoiceTwo; bool goAgain = true; while(goAgain) { cout << "What would you like to do?\n"; cout << "\t1. Enter some Magical Creatures\n"; cout << "\t2. List/Print Creatures\n"; cout << "\t3. Print Statistics on Creature Cost\n"; cout << "\t4. End Program\n"; cout << "\tEnter 1, 2, 3, or 4.\n"; cout << "CHOICE: "; cin >> menuChoice; if (menuChoice == 1) //Beginning of menuChoice 1 enterCreatures(currentNumber, profile); else if (menuChoice == 2) //Beginning of menuChoice 2 printCreatures(currentNumber, profile); else if (menuChoice == 3) //Beginning of menuChoice 3 printStatistics(currentNumber, profile); else if (menuChoice == 4) //Beginning of menuChoice 4 { do { cout << "Would you like to save your creature list to a file? (y or n)"; cin >> menuChoiceTwo; if (menuChoiceTwo == 'y' || menuChoiceTwo == 'Y') saveCreaturesToFile(currentNumber, profile); else if (menuChoiceTwo == 'n' || menuChoiceTwo == 'N') else //validating user input { cout << "You did not enter y or n!\n"; cout << "Please enter either y or n: "; } } while (!(menuChoiceTwo == 'y' || menuChoiceTwo == 'Y' || menuChoiceTwo == 'n' || menuChoiceTwo == 'N')) goAgain = false; } else //Validating user input cout << "You did not enter a valid menu choice!\n"; } //End of while loop return 0; } void printStatistics(int num, Creatures profile[]) { double total = 0.0; //Accumulator, initialized with 0 double cost; cout << "COST OF EACH CREATURE FOR ONE WEEK:\n\n"; cout << "CREATURE"<< setw(35) << "COST\n"; for (int x = 0; x < SIZE; x++) { cout << profile[x].name << setw(25) << "$"; cost = profile[x].management.hours * profile[x].management.cost // this line was cut off so you may need to revise this cout << setw(35) << cost; total += cost; //Accumulate the running total } }