Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 ( 4 marks ) : Write a program to record information about pets in a pet store. The information consists of objects stored
Question marks: Write a program to record information about pets in a pet store. The information consists of objects stored in a list. The attributes in the objects are as follows: storename a class attribute set to the value "Pet Paradise" animaltype petname age cost The class is to have the following methods: initstr printstorename a class method checkanimaltype The user will given a menu with the following options: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file Quit You are to create an Exception class called PetCheck to check that the animaltype entered is either a dog, cat, bird or fish. All other types of animals should generate an error message. You should also check the entered menu option, age and cost and generate a ValueError message if a ValueError occurs age is to be an int and cost is to be a float You should also check when you print out the average cost for a ZeroDivisionError and generate and error message of this occurs. Create a function for each of the menu options except Quit You will need to pass your list to these functions and return the list from them. You may pass or return other fields also if needed. When you load information from a file, make sure to first clear the list. Loading a file is to replace any existing information in the list with the information from the file. REQUIREMENTS Your program must follow the instructions above. Your code must be based only on the materials covered in weeks to of the course. Your output must appear exactly like the following example the text in bold indicates the user input Sample Output: Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Error: There are no pets in the store divide by zero Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: dogEnter pet name: FidoEnter pet age: Enter cost of pet: Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: horseError: You can only select a dog, cat, bird, or fish Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: catEnter pet name: Mister MittensEnter pet age: Error: Age must be entered as an integer Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: catEnter pet name: Mister MittensEnter pet age: Enter cost of pet: cheapError: Cost must be entered as an integer or float Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: catEnter pet name: Mister MittensEnter pet age: Enter cost of pet: Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Store name: Pet ParadiseFido dog age $Mister Mittens cat age $ Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Store name: Pet ParadiseTotal cost of pets: $Average cost of pets: $ Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter name of file to write: pets.csvFile written. Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter name of file to read: pets.csvFile loaded. Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Goodbye.
Question marks: Write a program to record information about pets in a pet store. The information consists of objects stored in a list. The attributes in the objects are as follows: storename a class attribute set to the value "Pet Paradise" animaltype petname age cost The class is to have the following methods: initstr printstorename a class method checkanimaltype The user will given a menu with the following options: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file Quit You are to create an Exception class called PetCheck to check that the animaltype entered is either a dog, cat, bird or fish. All other types of animals should generate an error message. You should also check the entered menu option, age and cost and generate a ValueError message if a ValueError occurs age is to be an int and cost is to be a float You should also check when you print out the average cost for a ZeroDivisionError and generate and error message of this occurs. Create a function for each of the menu options except Quit You will need to pass your list to these functions and return the list from them. You may pass or return other fields also if needed. When you load information from a file, make sure to first clear the list. Loading a file is to replace any existing information in the list with the information from the file. REQUIREMENTS Your program must follow the instructions above. Your code must be based only on the materials covered in weeks to of the course. Your output must appear exactly like the following example the text in bold indicates the user input Sample Output: Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Error: There are no pets in the store divide by zero Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: dogEnter pet name: FidoEnter pet age: Enter cost of pet: Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: horseError: You can only select a dog, cat, bird, or fish Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: catEnter pet name: Mister MittensEnter pet age: Error: Age must be entered as an integer Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: catEnter pet name: Mister MittensEnter pet age: Enter cost of pet: cheapError: Cost must be entered as an integer or float Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter animal type: catEnter pet name: Mister MittensEnter pet age: Enter cost of pet: Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Store name: Pet ParadiseFido dog age $Mister Mittens cat age $ Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Store name: Pet ParadiseTotal cost of pets: $Average cost of pets: $ Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter name of file to write: pets.csvFile written. Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Enter name of file to read: pets.csvFile loaded. Menu: Add a pet Print a list of all animals in the store Print total and average cost Save information to a file Load information from a file QuitPlease select an option: Goodbye.
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