Answered step by step
Verified Expert Solution
Link Copied!

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 -

CP1401/CP5639 Assignment 2Task Animal Accumulator:You are to plan and then code a medium-sized console-basedprogram in Python 3. This assignment is designed to help you build skills using: As in assignment 1: Input, Processing and Output; Decision structures; Repetition structures New in assignment 2: 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:100% 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 0-100 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:(W)aito This simulates a day starting with luck between 0 and 100. If you get less than 42(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 /100* name lengthe.g., if luck is 70, a "Zebra" animal (5 characters) would generate 0.7*5=3.5 as aninteger, so an income of 3.(D)isplay animalso This simply displays the animals (or No animals. if you have none).(A)dd 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 error-check 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 11 income).When you add an animal, the name length (cost) is deducted from your total income.(Q)uito 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

Find the APR compounded daily which is equivalent to 10% per year.

Answered: 1 week ago