SlideShare a Scribd company logo
1 of 17
Beholder#Giant center eye and twelve eye stalks above it. It is
a flying eyeball. Mouth full of razor sharp teeth. Eye stalks
shoot various beams of magical death-dealing
energy.#7#8#Underground#1#0#1000#700#0#Banshee#The
English Banshee is a fairy woman who wails when death is
approaching.They do not cause death, only mourn it. Banshees
are almost always female, and are usually seen with long, dark,
black hair and pale chees. Their eyes also are usually red from
crying.#0#0#Irish#0#1#15.5#0#25#Sasquatch#Sasquatch is
large, hairy, man-shaped creature that live in the forests of
North America, especially around the border of the US and
Canada. Like their cousin in the Himalayas (known as Yeti)
they have been glimpsed at by many, but no proof of their
existance has been found except the odd fur and footprints.
Sasquatch is also known as Bigfoot.#0#7.5#US and
Canada#1#15.75#8.5#265.75#12.4#Troll#Ugly and big.
Sometimes smell bad.#0#8.2#Wooded areas#1#8#1#1#3.45#
PROGRAM 4 / CSC 2100-001
Magical Creatures Zoo
©http://harrypotter.wikia.com/wiki/Rubeus_Hagrid
Assignment Date: Monday, April 7, 2014
Due Date: Wednesday, April 23, 2014 by midnight – NO LATE
SUBMISSIONS!!!
What to Turn In:
• Zip & upload to PROGRAM 4 ilearn dropbox prog4.cpp,
prog4.h, functions.cpp
Description:
Your assignment is to write a program for a Magical Creatures
Zookeeper. The zookeeper can house up to 100 magical
creatures. Information about each creature needs will be kept
and manipulated in this program. The user should be
able to load magical creature information from any file he or
she chooses, add creatures manually, delete a creature,
print creature information to either a file or to the screen, or
print a cost analysis of each creature and then the total
cost to house and take care of these creatures.
What’s New in Program 5:
• Structures (structure array, nested structures)
PROGRAM SPECIFICATIONS
Structures: (define all structures in Prog4.h)
You will need to create two structures. One is called Cost.
Cost will have the following members:
• The number of hours it takes to take care of a specific
creature.
• The cost (per hour) of taking care of this creature.
• The cost of food to feed this creature for one week.
• The cost of materials/supplies (grooming, medical) for this
creature for one week
The second structure is called Creatures. Creatures will have
the following members:
• The name of the creature
• The description of the creature
• The average length of the creature (in feet)
• The average height of the creature (in feet)
• The location of the creature (example: its origin or where they
are commonly found)
• If the creature is dangerous (Boolean variable)
• A variable to hold the Cost structure members
©http://www.fanpop.com/clubs/magical-
creatures/images/7845099/title/unicorns-wallpaper
The Main Function: (define main function in Prog4.cpp)
You will need to create an array of 100 elements of the
Creatures data type. You will also need to create a variable that
will keep up with the current number of creatures.
The main function will display a menu of five options:
1. Enter some Magical Creatures.
2. Delete a Magical Creature
3. List/Print Creatures.
4. Print Creature Costs.
5. End Program.
Make sure you always validate all user choices in the whole
program before proceeding to do what the user wants. Each
menu choice will call a function that you will create.
If the user chooses option 1, then your program will call the
enterCreatures function. If the user chooses option 2, then
your program will call the deleteCreature function. If the user
chooses option 3, then your program will call the
printCreatures function. If the user chooses option 4, then your
program will call the printStatistics function. If the user
chooses option 5, then your program will ask the user if they
wish to save their creature list to a file. If they choose yes,
then your program should call the saveCreaturesToFile function
and then end. If they choose no, then your program
should just end.
ALL OTHER FUNCTIONS SHOULD BE DEFINED IN
functions.cpp
enterCreatures function
The enterCreatures() function takes two parameters: the number
of creatures currently loaded in the Creatures array
and the Creatures array. The function will return the new
number of creatures. Before trying to add any creatures, this
function should first check to make sure the number of creatures
isn’t already 100. Because if it is, then your program
should not add any creatures, but should instead tell the user
that their zoo is at full capacity and that they are not able
to add creatures. Then the function should end.
Otherwise, your program will display a menu asking the user if
they would like to do one of the following:
1. Load my creatures from a file.
2. Enter one creature manually.
Validate the user’s choice.
If the user chooses option 1, then ask the user what the name of
the file is that they would like to load the creatures
from. Then open their file. Check if the file could open before
reading from it.
Read each creature from the file and place them in the Creatures
array, making sure that you increment the number of
creatures each time a creature is added. When you are reading
from the file, everything read in will have to be read in
as a string. Some of the Creature members are strings, so that
won’t be a problem. However, some of the Creature
members are floats. So, this function will have to call the
convertToFloat() function (provided later) in order to convert
the string to a float and then placed in the Creatures array.
Then return the number of creatures at the end of the
function.
If the user chooses option 2, then you will want to start a loop
so that the user can add multiple creatures manually
without returning to the main menu. Ask the user for the
following: (make sure you place each bit of information in the
correct place in the Creatures array)
• NAME:
• DESCRIPTION:
• AVERAGE LENGTH (in feet):
• AVERAGE HEIGHT (in feet):
• LOCATION:
• IS IT A DANGEROUS CREATURE? (y or n)
• How many hours do you spend caring for the [insert creature
name here]?
NUM HOURS:
• What is the cost per hour for caring for the [insert creature
name here]?
COST PER HOUR:
• How much money do you spend on food for the [insert
creature name here]?
FOOD COST:
• How much money do you spend on grooming and medical
supplies for the [insert creature name here]?
SUPPLY COST:
Then, increment the number of creatures by one. Then, ask the
user if they want to add another creature. If they do,
then repeat this option. If not, then just return the number of
creatures.
deleteCreature function
The deleteCreature() function has two parameters: the current
number of creatures in the Creatures array and the
Creatures array. This function returns the new number of
creatures.
First, this function will say “The following is a list of all the
creatures you take care of: “ and then it will say the name of
each creature. Then, your program will ask the user
What creature do you wish to remove?
CREATURE NAME:
Your program should then read in the name and place it in a
variable. Then, this function will call the
moveArrayElements function, which will take care of removing
the creature. The moveArrayElements function returns a
Boolean value to tell if the creature was removed of not. Check
to see if the creature was removed. If it was, then
decrement the number of creatures and print out “You have
removed [insert creature name here].” Then return the
new number of creatures.
moveArrayElements function
The moveArrayElements() function has the following
parameters: a string with the name of the creature that the user
wishes to remove, the current number of creatures in the
Creature array, and the Creatures array. This function returns
a Boolean variable that is true if the creature was removed and
false if it was not removed.
This function should first find the subscript number of the
creature that needs to be removed. Once that is found, then
you know there is a creature in the Creatures array by that name
and that your program will be able to remove it. If
your program cannot find the creature in the array, then you
return false from this function. Otherwise, this function
should now overwrite the element with the creature to delete (x)
with the next element in the array (x+1), moving each
element after the deleted element to the left. Then return true
that the creature was found & removed.
©http://www.dragoart.com/tuts/9077/1/1/how-to-draw-a-
banshee,-banshee.htm
printCreatures function
The printCreatures() function is a void function and contains the
following parameters: number of creatures currently in
the Creatures array and the Creatures array. The
printCreatures() function will first display a menu to the user
containing the following options:
• Print Creatures to the Screen.
• Print Creatures to a File.
Validate the user’s choice. If the user chooses option 1, then
you will print out all the creatures in the Creatures array to
the screen in the following format:
Notice that the description does word wrapping. In other
words, each word is not split up – they are kept together.
If the user selects option 2, then your program should ask the
user what is the name of the file that they wish to print
the creatures to. Then, open this file. You do not have to check
for errors for this file because it probably will not yet
exist. Then, write all the information to the file like you did to
the screen if the user had chosen option 1. Example
below:
Then, your program should write “Your creatures have been
written to [insert filename here].”
printStatistics function
The printStatistics() function is a void function and it contains
two parameters: the current number of creatures in the
Creatures array and the Creatures array.
This function should print out the total cost of each creature in
a table. To figure out the cost of a creature, use the
formula:
Cost = numHours * costPerHour + foodCost + materialCost
Then, this function should also keep a running total of the total
cost of all the creatures.
The table printed should look like this:
saveCreaturesToFile function
The saveCreaturesToFile() function is a void function and it
contains two parameters: the current number of creatures in
the Creatures array and the Creatures array. The function
should ask the user what the name of the file that they wish
to save their creatures to. The function should then open that
file and write out all the creature data in the following
order:
• Name
• Description
• Avg. Length
• Avg. Height
• Location
• Dangerous
• numHours
• costPerHour
• foodCost
• MaterialCost
There should be no newlines or endlines in the file. All data
should be separated by a pound sign (#) instead of a space.
After printing all data from the Creatures array to the file, this
function should print out a message to standard output
saying “Your creatures were successfully saved to the [insert
filename here] file.”
convertToFloat function
The convertToFloat() function will need to be used when
reading data from a file and inputting the data into the
Creatures array (so this function will be called from the
enterCreatures function). I am providing this function for you.
You just need to insert it into your program so you can use it.
float convertToFloat(string s)
{
istringstream i(s);
float x;
if (!(i >> x))
x = 0;
return x;
}
You will need to insert the following header file to use the
convertToFloat function:
#include <sstream>
©https://www.wizards.com/DnD/Article.aspx?x=dnd/4ex/20090
508
©https://itunes.apple.com/us/app/magic-zoo/id434356619?mt=8
EXAMPLE OUTPUT
Screen shot of creature.txt:
Screen shot of running Prog4.exe
Screen shot of creat04072014.txt:
Screen shot continued of Prog4.exe:
Screenshot of creatInput04072014.txt:
PROGRAM 4 -
Magical Creature Zoo
NAME:
Earned
Points
Possible Points
Detailed Description
5 Compiling / Syntax Errors
Compiles with no errors – 5 points
Does not compile – 0 points
85 Specifications
10 Source/Header Files: (10 points)
• Main function is in its own source file (Prog5.cpp)
• Programmer-defined functions in separate file (functions.cpp)
• #include headers, structure definitions and function
prototypes are all in header file (Prog5.h)
5 Creatures Text File (5 points)
• Submitted a text file with information on 10 creatures
• All data is separated by a pound sign.
5 Structures (5 points)
• Cost Structure
• Creatures structure
10 Main Function (10 points)
• Creation of Creatures array (100 elements)
• Shows main menu / correct choices
• Runs until user chooses option 5
• Validate user choice
• Function call statements
• saveCreaturesToFile if user wants to after choosing option 5
15 enterCreatures Function (15 points)
• Check if current # of creatures is less than 100, error
message if equal to 100.
• Menu of two choices
• Validate user’s choice
CHOICE 1
• Ask user for filename
• Open file as input
• Check file for errors
• Read from file using getline, while loop (eof) and increment
num creatures.
• Close file
• Confirmation message
CHOICE 2
• Ask user for each piece of data in specified/neat way
• Read data from standard input
• Place data in Creatures array in correct element.
• Choice 2 happens as many times as user wants it to
• Confirmation message
Earned
Points
Possible Points
Detailed Description
10 deleteCreature Function (10 points)
• List each creature’s name
• Ask user which one they want to delete
• Send the name of the one to delete to mAE(), returning a
bool if it was removed.
• If removed, decrement num creatures
• Confirmation message if it was removed or not.
5 moveArrayElements Function (5 points)
• Use for loop to see if string sent in matches any in the array.
• If found, for loop to move array elements & return true
• If not found, return false
15 printCreatures Function (15 points)
• Menu of two options
• Validate user’s choice
CHOICE 1
• Print each creature to the screen
• Neat/uses stream manipulators
• BONUS (5 points) does word wrapping for description
CHOICE 2
• Ask user for filename
• Open file as output file
• Print each creature to the file
• Neat/uses stream manipulators
• Close file
• Confirmation message
5 printStatistics Function (5 points)
• Cost of each creature per week is printed out with for loop
• Total cost of all creatures is printed out
5 saveCreaturesToFile Function (5 points)
• Filename is acquired from user
• File is opened as output file
• Use for loop to print out creatures to file with # between each
piece of data
• File is closed
• Confirmation message
10 Readability of
Code
Sufficient comments in code & naming of variables
Includes comment block at top containing title of program, date,
author, and purpose of program.
Code is indented properly.
(only
subtracts
from grade)
Delivery Program received by email before midnight -
Wednesday April 23rd.
DATE/TIME Delivered:
100 TOTAL (FINAL) GRADE
Beholder#Giant center eye and twelve eye stalks above it.  It is a.docx

More Related Content

Similar to Beholder#Giant center eye and twelve eye stalks above it. It is a.docx

Genetic programming with clojure.spec and Beyond
Genetic programming with clojure.spec and BeyondGenetic programming with clojure.spec and Beyond
Genetic programming with clojure.spec and Beyond
Carin Meier
 
The purpose of this project is to give students more exposure to obje.pdf
The purpose of this project is to give students more exposure to obje.pdfThe purpose of this project is to give students more exposure to obje.pdf
The purpose of this project is to give students more exposure to obje.pdf
forwardcom41
 

Similar to Beholder#Giant center eye and twelve eye stalks above it. It is a.docx (20)

Python Traning presentation
Python Traning presentationPython Traning presentation
Python Traning presentation
 
Java session4
Java session4Java session4
Java session4
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Lecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and CollectionsLecture 4 - Object Interaction and Collections
Lecture 4 - Object Interaction and Collections
 
Computer notes - data structures
Computer notes - data structuresComputer notes - data structures
Computer notes - data structures
 
Genetic programming with clojure.spec and Beyond
Genetic programming with clojure.spec and BeyondGenetic programming with clojure.spec and Beyond
Genetic programming with clojure.spec and Beyond
 
Behat 3.0 meetup (March)
Behat 3.0 meetup (March)Behat 3.0 meetup (March)
Behat 3.0 meetup (March)
 
The purpose of this project is to give students more exposure to obje.pdf
The purpose of this project is to give students more exposure to obje.pdfThe purpose of this project is to give students more exposure to obje.pdf
The purpose of this project is to give students more exposure to obje.pdf
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
Cs in science_guides
Cs in science_guidesCs in science_guides
Cs in science_guides
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers
 
jQuery
jQueryjQuery
jQuery
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
Oops
OopsOops
Oops
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlin
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 

More from ikirkton

Analyze MVPIThe motives, values, and preferences inventory (MV.docx
Analyze MVPIThe motives, values, and preferences inventory (MV.docxAnalyze MVPIThe motives, values, and preferences inventory (MV.docx
Analyze MVPIThe motives, values, and preferences inventory (MV.docx
ikirkton
 
Analyze and interpret the following quotation The confrontation of.docx
Analyze and interpret the following quotation The confrontation of.docxAnalyze and interpret the following quotation The confrontation of.docx
Analyze and interpret the following quotation The confrontation of.docx
ikirkton
 
Analyze and prepare a critique of the following situationMary h.docx
Analyze and prepare a critique of the following situationMary h.docxAnalyze and prepare a critique of the following situationMary h.docx
Analyze and prepare a critique of the following situationMary h.docx
ikirkton
 
Analyze financial statements using financial ratios.• .docx
Analyze financial statements using financial ratios.• .docxAnalyze financial statements using financial ratios.• .docx
Analyze financial statements using financial ratios.• .docx
ikirkton
 
Analyze and prepare a critique of the following situationMary has.docx
Analyze and prepare a critique of the following situationMary has.docxAnalyze and prepare a critique of the following situationMary has.docx
Analyze and prepare a critique of the following situationMary has.docx
ikirkton
 
An investment has an installed cost of $673,658. The cash flows ov.docx
An investment has an installed cost of $673,658. The cash flows ov.docxAn investment has an installed cost of $673,658. The cash flows ov.docx
An investment has an installed cost of $673,658. The cash flows ov.docx
ikirkton
 
An expanded version of the accounting equation could be A + .docx
An expanded version of the accounting equation could be  A + .docxAn expanded version of the accounting equation could be  A + .docx
An expanded version of the accounting equation could be A + .docx
ikirkton
 

More from ikirkton (20)

Analyze MVPIThe motives, values, and preferences inventory (MV.docx
Analyze MVPIThe motives, values, and preferences inventory (MV.docxAnalyze MVPIThe motives, values, and preferences inventory (MV.docx
Analyze MVPIThe motives, values, and preferences inventory (MV.docx
 
Analyze and interpret the following quotation The confrontation of.docx
Analyze and interpret the following quotation The confrontation of.docxAnalyze and interpret the following quotation The confrontation of.docx
Analyze and interpret the following quotation The confrontation of.docx
 
Analyze and prepare a critique of the following situationMary h.docx
Analyze and prepare a critique of the following situationMary h.docxAnalyze and prepare a critique of the following situationMary h.docx
Analyze and prepare a critique of the following situationMary h.docx
 
Analyze the anthropological film Jero A Balinese Trance Seance made.docx
Analyze the anthropological film Jero A Balinese Trance Seance made.docxAnalyze the anthropological film Jero A Balinese Trance Seance made.docx
Analyze the anthropological film Jero A Balinese Trance Seance made.docx
 
analyze and synthesize the financial reports of an organization of t.docx
analyze and synthesize the financial reports of an organization of t.docxanalyze and synthesize the financial reports of an organization of t.docx
analyze and synthesize the financial reports of an organization of t.docx
 
Analyze financial statements using financial ratios.• .docx
Analyze financial statements using financial ratios.• .docxAnalyze financial statements using financial ratios.• .docx
Analyze financial statements using financial ratios.• .docx
 
Analyze and prepare a critique of the following situationMary has.docx
Analyze and prepare a critique of the following situationMary has.docxAnalyze and prepare a critique of the following situationMary has.docx
Analyze and prepare a critique of the following situationMary has.docx
 
Analyze Alternative Exchange Rate RegimesThere are several argum.docx
Analyze Alternative Exchange Rate RegimesThere are several argum.docxAnalyze Alternative Exchange Rate RegimesThere are several argum.docx
Analyze Alternative Exchange Rate RegimesThere are several argum.docx
 
Analyze and evaluate the different leadership theories and behavior .docx
Analyze and evaluate the different leadership theories and behavior .docxAnalyze and evaluate the different leadership theories and behavior .docx
Analyze and evaluate the different leadership theories and behavior .docx
 
Analytical essay report about polio 1ِ- An introductory paragraph .docx
Analytical essay report about polio 1ِ- An introductory paragraph .docxAnalytical essay report about polio 1ِ- An introductory paragraph .docx
Analytical essay report about polio 1ِ- An introductory paragraph .docx
 
Analysis Essay 1DUE Feb 23, 2014 1155 PMGrade DetailsGrade.docx
Analysis Essay 1DUE Feb 23, 2014 1155 PMGrade DetailsGrade.docxAnalysis Essay 1DUE Feb 23, 2014 1155 PMGrade DetailsGrade.docx
Analysis Essay 1DUE Feb 23, 2014 1155 PMGrade DetailsGrade.docx
 
AnalogíasComplete the analogies. Follow the model.Modelomuer.docx
AnalogíasComplete the analogies. Follow the model.Modelomuer.docxAnalogíasComplete the analogies. Follow the model.Modelomuer.docx
AnalogíasComplete the analogies. Follow the model.Modelomuer.docx
 
ANA Buenos días, señor González. ¿Cómo (1) (2) SR. GONZÁLEZ .docx
ANA Buenos días, señor González. ¿Cómo (1)  (2) SR. GONZÁLEZ .docxANA Buenos días, señor González. ¿Cómo (1)  (2) SR. GONZÁLEZ .docx
ANA Buenos días, señor González. ¿Cómo (1) (2) SR. GONZÁLEZ .docx
 
Analyze symbolism in Jane Eyre from a Feminist point of view.  Exa.docx
Analyze symbolism in Jane Eyre from a Feminist point of view.  Exa.docxAnalyze symbolism in Jane Eyre from a Feminist point of view.  Exa.docx
Analyze symbolism in Jane Eyre from a Feminist point of view.  Exa.docx
 
An important part of research is finding sources that can be trusted.docx
An important part of research is finding sources that can be trusted.docxAn important part of research is finding sources that can be trusted.docx
An important part of research is finding sources that can be trusted.docx
 
An investment has an installed cost of $673,658. The cash flows ov.docx
An investment has an installed cost of $673,658. The cash flows ov.docxAn investment has an installed cost of $673,658. The cash flows ov.docx
An investment has an installed cost of $673,658. The cash flows ov.docx
 
An incomplete Punnett square There are three possible phenotypes fo.docx
An incomplete Punnett square There are three possible phenotypes fo.docxAn incomplete Punnett square There are three possible phenotypes fo.docx
An incomplete Punnett square There are three possible phenotypes fo.docx
 
An expanded version of the accounting equation could be A + .docx
An expanded version of the accounting equation could be  A + .docxAn expanded version of the accounting equation could be  A + .docx
An expanded version of the accounting equation could be A + .docx
 
An Evolving IndustryHow are the Internet and other technologies cu.docx
An Evolving IndustryHow are the Internet and other technologies cu.docxAn Evolving IndustryHow are the Internet and other technologies cu.docx
An Evolving IndustryHow are the Internet and other technologies cu.docx
 
An essay addressing the definition or resemblance concerning categor.docx
An essay addressing the definition or resemblance concerning categor.docxAn essay addressing the definition or resemblance concerning categor.docx
An essay addressing the definition or resemblance concerning categor.docx
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 

Beholder#Giant center eye and twelve eye stalks above it. It is a.docx

  • 1. Beholder#Giant center eye and twelve eye stalks above it. It is a flying eyeball. Mouth full of razor sharp teeth. Eye stalks shoot various beams of magical death-dealing energy.#7#8#Underground#1#0#1000#700#0#Banshee#The English Banshee is a fairy woman who wails when death is approaching.They do not cause death, only mourn it. Banshees are almost always female, and are usually seen with long, dark, black hair and pale chees. Their eyes also are usually red from crying.#0#0#Irish#0#1#15.5#0#25#Sasquatch#Sasquatch is large, hairy, man-shaped creature that live in the forests of North America, especially around the border of the US and Canada. Like their cousin in the Himalayas (known as Yeti) they have been glimpsed at by many, but no proof of their existance has been found except the odd fur and footprints. Sasquatch is also known as Bigfoot.#0#7.5#US and Canada#1#15.75#8.5#265.75#12.4#Troll#Ugly and big. Sometimes smell bad.#0#8.2#Wooded areas#1#8#1#1#3.45# PROGRAM 4 / CSC 2100-001 Magical Creatures Zoo ©http://harrypotter.wikia.com/wiki/Rubeus_Hagrid Assignment Date: Monday, April 7, 2014 Due Date: Wednesday, April 23, 2014 by midnight – NO LATE SUBMISSIONS!!! What to Turn In: • Zip & upload to PROGRAM 4 ilearn dropbox prog4.cpp,
  • 2. prog4.h, functions.cpp Description: Your assignment is to write a program for a Magical Creatures Zookeeper. The zookeeper can house up to 100 magical creatures. Information about each creature needs will be kept and manipulated in this program. The user should be able to load magical creature information from any file he or she chooses, add creatures manually, delete a creature, print creature information to either a file or to the screen, or print a cost analysis of each creature and then the total cost to house and take care of these creatures. What’s New in Program 5: • Structures (structure array, nested structures) PROGRAM SPECIFICATIONS Structures: (define all structures in Prog4.h) You will need to create two structures. One is called Cost. Cost will have the following members: • The number of hours it takes to take care of a specific creature. • The cost (per hour) of taking care of this creature. • The cost of food to feed this creature for one week. • The cost of materials/supplies (grooming, medical) for this creature for one week The second structure is called Creatures. Creatures will have the following members: • The name of the creature
  • 3. • The description of the creature • The average length of the creature (in feet) • The average height of the creature (in feet) • The location of the creature (example: its origin or where they are commonly found) • If the creature is dangerous (Boolean variable) • A variable to hold the Cost structure members ©http://www.fanpop.com/clubs/magical- creatures/images/7845099/title/unicorns-wallpaper The Main Function: (define main function in Prog4.cpp) You will need to create an array of 100 elements of the Creatures data type. You will also need to create a variable that will keep up with the current number of creatures. The main function will display a menu of five options: 1. Enter some Magical Creatures. 2. Delete a Magical Creature 3. List/Print Creatures. 4. Print Creature Costs. 5. End Program. Make sure you always validate all user choices in the whole program before proceeding to do what the user wants. Each menu choice will call a function that you will create. If the user chooses option 1, then your program will call the enterCreatures function. If the user chooses option 2, then
  • 4. your program will call the deleteCreature function. If the user chooses option 3, then your program will call the printCreatures function. If the user chooses option 4, then your program will call the printStatistics function. If the user chooses option 5, then your program will ask the user if they wish to save their creature list to a file. If they choose yes, then your program should call the saveCreaturesToFile function and then end. If they choose no, then your program should just end. ALL OTHER FUNCTIONS SHOULD BE DEFINED IN functions.cpp enterCreatures function The enterCreatures() function takes two parameters: the number of creatures currently loaded in the Creatures array and the Creatures array. The function will return the new number of creatures. Before trying to add any creatures, this function should first check to make sure the number of creatures isn’t already 100. Because if it is, then your program should not add any creatures, but should instead tell the user that their zoo is at full capacity and that they are not able to add creatures. Then the function should end. Otherwise, your program will display a menu asking the user if they would like to do one of the following: 1. Load my creatures from a file. 2. Enter one creature manually. Validate the user’s choice. If the user chooses option 1, then ask the user what the name of the file is that they would like to load the creatures from. Then open their file. Check if the file could open before
  • 5. reading from it. Read each creature from the file and place them in the Creatures array, making sure that you increment the number of creatures each time a creature is added. When you are reading from the file, everything read in will have to be read in as a string. Some of the Creature members are strings, so that won’t be a problem. However, some of the Creature members are floats. So, this function will have to call the convertToFloat() function (provided later) in order to convert the string to a float and then placed in the Creatures array. Then return the number of creatures at the end of the function. If the user chooses option 2, then you will want to start a loop so that the user can add multiple creatures manually without returning to the main menu. Ask the user for the following: (make sure you place each bit of information in the correct place in the Creatures array) • NAME: • DESCRIPTION: • AVERAGE LENGTH (in feet): • AVERAGE HEIGHT (in feet): • LOCATION: • IS IT A DANGEROUS CREATURE? (y or n) • How many hours do you spend caring for the [insert creature name here]? NUM HOURS: • What is the cost per hour for caring for the [insert creature name here]?
  • 6. COST PER HOUR: • How much money do you spend on food for the [insert creature name here]? FOOD COST: • How much money do you spend on grooming and medical supplies for the [insert creature name here]? SUPPLY COST: Then, increment the number of creatures by one. Then, ask the user if they want to add another creature. If they do, then repeat this option. If not, then just return the number of creatures. deleteCreature function The deleteCreature() function has two parameters: the current number of creatures in the Creatures array and the Creatures array. This function returns the new number of creatures. First, this function will say “The following is a list of all the creatures you take care of: “ and then it will say the name of each creature. Then, your program will ask the user What creature do you wish to remove? CREATURE NAME: Your program should then read in the name and place it in a variable. Then, this function will call the moveArrayElements function, which will take care of removing the creature. The moveArrayElements function returns a Boolean value to tell if the creature was removed of not. Check
  • 7. to see if the creature was removed. If it was, then decrement the number of creatures and print out “You have removed [insert creature name here].” Then return the new number of creatures. moveArrayElements function The moveArrayElements() function has the following parameters: a string with the name of the creature that the user wishes to remove, the current number of creatures in the Creature array, and the Creatures array. This function returns a Boolean variable that is true if the creature was removed and false if it was not removed. This function should first find the subscript number of the creature that needs to be removed. Once that is found, then you know there is a creature in the Creatures array by that name and that your program will be able to remove it. If your program cannot find the creature in the array, then you return false from this function. Otherwise, this function should now overwrite the element with the creature to delete (x) with the next element in the array (x+1), moving each element after the deleted element to the left. Then return true that the creature was found & removed. ©http://www.dragoart.com/tuts/9077/1/1/how-to-draw-a- banshee,-banshee.htm printCreatures function The printCreatures() function is a void function and contains the following parameters: number of creatures currently in
  • 8. the Creatures array and the Creatures array. The printCreatures() function will first display a menu to the user containing the following options: • Print Creatures to the Screen. • Print Creatures to a File. Validate the user’s choice. If the user chooses option 1, then you will print out all the creatures in the Creatures array to the screen in the following format: Notice that the description does word wrapping. In other words, each word is not split up – they are kept together. If the user selects option 2, then your program should ask the user what is the name of the file that they wish to print the creatures to. Then, open this file. You do not have to check for errors for this file because it probably will not yet exist. Then, write all the information to the file like you did to the screen if the user had chosen option 1. Example below: Then, your program should write “Your creatures have been written to [insert filename here].” printStatistics function The printStatistics() function is a void function and it contains two parameters: the current number of creatures in the Creatures array and the Creatures array. This function should print out the total cost of each creature in
  • 9. a table. To figure out the cost of a creature, use the formula: Cost = numHours * costPerHour + foodCost + materialCost Then, this function should also keep a running total of the total cost of all the creatures. The table printed should look like this: saveCreaturesToFile function The saveCreaturesToFile() function is a void function and it contains two parameters: the current number of creatures in the Creatures array and the Creatures array. The function should ask the user what the name of the file that they wish to save their creatures to. The function should then open that file and write out all the creature data in the following order: • Name • Description • Avg. Length • Avg. Height • Location • Dangerous • numHours • costPerHour • foodCost • MaterialCost There should be no newlines or endlines in the file. All data should be separated by a pound sign (#) instead of a space.
  • 10. After printing all data from the Creatures array to the file, this function should print out a message to standard output saying “Your creatures were successfully saved to the [insert filename here] file.” convertToFloat function The convertToFloat() function will need to be used when reading data from a file and inputting the data into the Creatures array (so this function will be called from the enterCreatures function). I am providing this function for you. You just need to insert it into your program so you can use it. float convertToFloat(string s) { istringstream i(s); float x; if (!(i >> x)) x = 0; return x; } You will need to insert the following header file to use the convertToFloat function: #include <sstream> ©https://www.wizards.com/DnD/Article.aspx?x=dnd/4ex/20090 508 ©https://itunes.apple.com/us/app/magic-zoo/id434356619?mt=8 EXAMPLE OUTPUT
  • 11. Screen shot of creature.txt: Screen shot of running Prog4.exe Screen shot of creat04072014.txt: Screen shot continued of Prog4.exe:
  • 12. Screenshot of creatInput04072014.txt: PROGRAM 4 - Magical Creature Zoo NAME: Earned Points Possible Points Detailed Description 5 Compiling / Syntax Errors Compiles with no errors – 5 points Does not compile – 0 points 85 Specifications 10 Source/Header Files: (10 points) • Main function is in its own source file (Prog5.cpp) • Programmer-defined functions in separate file (functions.cpp) • #include headers, structure definitions and function
  • 13. prototypes are all in header file (Prog5.h) 5 Creatures Text File (5 points) • Submitted a text file with information on 10 creatures • All data is separated by a pound sign. 5 Structures (5 points) • Cost Structure • Creatures structure 10 Main Function (10 points) • Creation of Creatures array (100 elements) • Shows main menu / correct choices • Runs until user chooses option 5 • Validate user choice • Function call statements • saveCreaturesToFile if user wants to after choosing option 5 15 enterCreatures Function (15 points) • Check if current # of creatures is less than 100, error message if equal to 100. • Menu of two choices • Validate user’s choice CHOICE 1 • Ask user for filename
  • 14. • Open file as input • Check file for errors • Read from file using getline, while loop (eof) and increment num creatures. • Close file • Confirmation message CHOICE 2 • Ask user for each piece of data in specified/neat way • Read data from standard input • Place data in Creatures array in correct element. • Choice 2 happens as many times as user wants it to • Confirmation message Earned Points Possible Points Detailed Description 10 deleteCreature Function (10 points) • List each creature’s name • Ask user which one they want to delete • Send the name of the one to delete to mAE(), returning a bool if it was removed. • If removed, decrement num creatures • Confirmation message if it was removed or not.
  • 15. 5 moveArrayElements Function (5 points) • Use for loop to see if string sent in matches any in the array. • If found, for loop to move array elements & return true • If not found, return false 15 printCreatures Function (15 points) • Menu of two options • Validate user’s choice CHOICE 1 • Print each creature to the screen • Neat/uses stream manipulators • BONUS (5 points) does word wrapping for description CHOICE 2 • Ask user for filename • Open file as output file • Print each creature to the file • Neat/uses stream manipulators • Close file • Confirmation message 5 printStatistics Function (5 points) • Cost of each creature per week is printed out with for loop • Total cost of all creatures is printed out 5 saveCreaturesToFile Function (5 points) • Filename is acquired from user • File is opened as output file
  • 16. • Use for loop to print out creatures to file with # between each piece of data • File is closed • Confirmation message 10 Readability of Code Sufficient comments in code & naming of variables Includes comment block at top containing title of program, date, author, and purpose of program. Code is indented properly. (only subtracts from grade) Delivery Program received by email before midnight - Wednesday April 23rd. DATE/TIME Delivered: 100 TOTAL (FINAL) GRADE