Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**Important, please read thoroughly** I have tired all the other answer to this question but none seem to work for me. I can't seem to

**Important, please read thoroughly** I have tired all the other answer to this question but none seem to work for me. I can't seem to figure out where I need to put the given "animals.txt" file or All the other answers seem to not be able to open the "verse.txt" file like it is supposed to do. I hope someone can help me with this because I am very lost.

image text in transcribedimage text in transcribedimage text in transcribed

Old MacDonald Program Problem Summary: For this program, you will be displaying the "Old MacDonald had a Farm" nursey rhyme about a farmer named MacDonald and the various animals he keeps on his farm. Each verse of the song changes the name of the animal and its respective noise. Input: - The program will read a text file named: "animals.txt". This file has been provided for you. Each line of the file contains the following information: animal amount - the amount of this particular animal animal name - the name of this particular animal animal noise - the noise this particular animal makes - Each input line has its fields separated by a space. - You will need to separate the fields in your program. As an easy method, you should create a list of your fields as in this example: animal_list = animal_line.split() \# This creates a list from the animal_line So, if your animal line is: ' 2 pig oink', then \( \begin{array}{ll}\text { animal_list }[0]='{ }^{\prime} \text { ' } & \# \text { An index of } 0 \text { is the amount } \\ \text { animal-list[1] }=\text { 'pig' } & \# \text { An index of } 1 \text { is the name } \\ \text { animal_list[2] }=\text { 'oink' } & \# \text { An index of } 2 \text { is the noise }\end{array} \) Calculations: - The program will increment the verse number and display the verse number before each verse. - The program will keep a running total for the number of animals Old MacDonald has and will display a total at the end of the program. Output: - The program will create a text file named: 'verses .txt' . - The program will display the verse number followed by verse. As an example, if your first line of input is: ' 2 pig oink', the program should display: Verse: 1 old MacDonald had a farm E-I-E-I-O And on his farm he had 2 pig's E-I-E-I-O With a oink oink here And a oink oink there Here a oink, there a oink Everywhere a oink oink old MacDonald had a farm E-I-E-I-O - if your second line of input is: ' 3 duck quack', the program should display: Verse: 2 Old MacDonald had a farm E-I-E-I-O And on his farm he had 3 duck's E-I-E-I-O With a quack quack here And a quack quack there Here a quack, there a quack Everywhere a quack quack Old MacDonald had a farm E-I-E-I-O - At the end of your program, the program should display a total line (which is calculated): old MacDonald has a total of 44 animals. - There should be a blank line separating each verse and a blank line before the total line.. Program Notes: - The program must use functions. - The program should use a trylexcept suite for reading and writing data Program Notes (continued): - A programmer header is required with the following information: \# Assignment: # \# Program Name: # \# Purpose: # \# Author: \# Course: # \# Created: - Global variables ANIMAL_FILE and VERSE_FILE should be used to identify the correct file names - The ANIMAL.FILE should be opened in read mode. - The VERSE_FILE should be opened in write mode

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

=+ Determine whether to use the direct or indirect approach.

Answered: 1 week ago