Starting from:

$30

Program #5: Weekly feed budget

COP 3223 Program #5: Weekly feed budget

Program: Weekly feed budget (feed.c)
The Orange County Sheriff's Office Mounted Unit has asked that you write a program to help
them manage their feed costs per week. The Mounted Unit includes twelve horses who each
have individualized feed plans that are reviewed by a vet once a month. The Sheriff's Office
would like you to write a program that reads in the vet's monthly plan and prints out a summary
of how much grain each horse requires each week and how much grain must be ordered each
week.
You may assume that, once a month, the vet will provide a data file called input.txt containing
twelve lines of data. Each line contains three values. The first value is the name of the horse,
the second value is the number of scoops of grain that horse should receive for breakfast each
day, and the third value is the number of scoops of grain that horse should receive for dinner
each day. One scoop equals 3.5 pounds of grain. One bag contains 50 pounds of grain.
You program should declare three arrays: name, breakfast, and dinner and read in and store
the data file values into these three arrays. You program must then calculate and print to the
screen: the amount of grain (in pounds) that each horse requires per week, the total amount of
grain (in pounds) required to feed everyone in one week, and the total number of bags of grain
that needs to be ordered each week.
Sample input file: oct2016.txt
Ditto 1.0 1.0
Leo 1.0 1.0
Major 1.5 1.5
Scooter 1.0 1.0
Diesel 1.5 1.5
Sierra 1.5 1.5
Salem 0.75 0.75
Senator 1.0 1.0
Oscar 0.75 0.75
Pete 1.0 1.0
Angelina 0.75 0.75
Blossom 1.0 1.0
Sample output for data file: oct2016.txt
Amount of grain per horse each week:
Ditto 49.00 pounds
Leo 49.00 pounds
Major 73.50 pounds
Scooter 49.00 pounds
Diesel 73.50 pounds
Sierra 73.50 pounds
Salem 36.75 pounds
Senator 49.00 pounds
Oscar 36.75 pounds
Pete 49.00 pounds
Angelina 36.75 pounds
Blossom 49.00 pounds
Total grain required each week: 624.75 pounds
Total grain to purchase each week: 13 bags
Some things to be aware of:
1. Make sure that the number of bags ordered is sufficient to meet the weekly need for grain.
For example, in the data above, 624.75 pounds equals approximately 12.5 bags. As a result, 13
bags must be ordered in order to cover the need.
2. In the list of the horses' weekly grain needs, please ensure that all weight values are lined up.
The horses' names may be either right or left justified.
3. Any amounts in pounds must be rounded to two decimal places. The number of bags may be
printed in either as an integer or double value but must be a whole number.
Deliverables
Please submit a file titled feed.c containing your solution to this problem to Webcourses by
Sunday, October 30, 2016 at 11:00 PM. Please submit your file to both the "Homework 5"
assignment and the "Homework 5 Peer Review" assignment.
Some notes:
1. Please ensure that your file includes header comments which include a good description of
your entire program.
2. Each function should be preceded by comments that give the pre-conditions, post-conditions,
and actions of that function.
3. All of your code should be commented. A good measure of the effectiveness of your
comments is whether I can understand the structure of each main program and function by the
comments alone (e.g. can I tell what your program and functions do if I deleted all of the code
and only had your comments).
4. All variables declared within a function must be declared at the start of your function. All
variables in the main program must be declared at the start of your main program.
5. Please ensure that your program reads from a data file called input.txt.
Program: feed.c

More products