Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CP 1 4 0 1 / CP 5 6 3 9 Assignment 2 Task Animal Accumulator:You are to plan and then code a medium -
CPCP Assignment Task Animal Accumulator:You are to plan and then code a mediumsized consolebasedprogram in Python This assignment is designed to help you build skills using: As in assignment : Input, Processing and Output; Decision structures; Repetition structures New in assignment : Functions and random numbers; Lists; FilesThe assignment also includes a developer's journal a document you complete as you plan andcode your program to help you focus on and improve your process and become a better developer.Incredibly Important: This assignment must not be where you first learn about these topics. Thesubject is designed to systematically teach you these principles through the lectures first then thepracticals. You should have practised each programming concept many times before you start usingit in your assignment. If you get to a point in your assignment where you're not sure about something,go back and learn from the subject teaching not on the Internet Remember: of what you need to know to complete this assignment is taught in the subject.Problem Description:Note: the sample output below should help explain and demonstrate all of the requirements.The Animal Accumulator is a program that simulates a collection of animals. You have a list ofanimals, which each generate "income" according to their name length as everyone knows, longeranimal names mean higher income... but they cost more to buy Each day when you wait, a random"luck" value between is generated, which determines how much income the animals generate,but if you are unlucky, a random animal will escape. You can buy new animals with the income youmake, but you cannot have more than one of each animal.The program starts with a welcome, some instructions and the option to load from a file of animals orstart with three animals. Then there's a repeating menu with the following four options:Waito This simulates a day starting with luck between and If you get less than thinkabout constants then a random animal from your list will escape and be deleted fromthe list. Animals are deleted before any income calculations.Each animal generates an amount of income according to the formula:integer luck name lengthe.g if luck is a "Zebra" animal characters would generate as aninteger, so an income of Display animalso This simply displays the animals or No animals. if you have noneAdd new animalo You can only add animals you can afford. You can have infinite animals but you cannothave any with the same name as existing animals. New animal names cannot beempty, so errorcheck and repeat for empty names.When you input an animal, the name should be converted to title case using Python's.title string method so if the user enters "HEARTy bass", it will become "HeartyBass" and would cost incomeWhen you add an animal, the name length cost is deducted from your total income.Quito This will end the main menu follow the pattern! and show the final details including theanimals, the number of days simulated, the number of animals and the amount ofincome. The user will be prompted to save the animals to the text file "animals.txt Ifthey enter y then the program should save each animal to the file, one name per line.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started