Question

Problem 3: HorseWeights In C++ Please Research shows that horses are satisfied when they consume an...

Problem 3: HorseWeights

In C++ Please

Research shows that horses are satisfied when they consume an amount equivalent to a certain percentage of their body weight on a daily basis. Depending on the horse type, some are satisfied with as little as 1.8% of their body weight, but others may require up to 3.2% of their body weight. An average of 2.0% is a good starting point for most “maintenance” and “light work” equines. The intake level for “moderate work” equines is slightly higher at 2.5%. For “growing” equines, “lactating” equines or equines that are subject to “heavy work” start with a 3.0% intake level. Given a list of horse weights and horse types, you are to make a program that should output the amount of feed that each horse needs. Attached is a list of 100 horse weights and horse types in the following format, with each horse weight and horse type on a single line:

1300 moderate work

700 growing

1232 moderate work

1300 heavy work

1320 lactating

760 growing

Read in the data into 2 arrays of appropriate type. Then make a function that will have 2 parameters; a single horse’s body weight, and the horse’s type. The function should return the horse’s amount of feed.

You will then output the index number for each horse, 1-100, and how much feed that equine should receive. (Note that we will use pounds for the body weight, and therefore our amount of feed will also be in pounds.)

Here is an example of some output – using the sample input from above:

Horse # Amount of Feed

1 32.5

2 21

3 30.8

4 39

5 39.6

6 22.8

0 0
Add a comment Improve this question Transcribed image text
Answer #1

'

# This function takes two inputs i.e. the weight of the horse and the type of the horse

# Then it returns the amount of food that needs to be fed to the horse

def food_needed(weight,type):

    if type== "growing" or type== "lactating" or type== "heavy work":

        return weight*0.03

    elif type =="maintenance" or type=="light work":

        return weight*0.02

    # If none of the above two cases get executed then it means that the horse is doing moderate work and its 2.5 percent of food needed

    else:

        return weight*0.025

# The line variable is for reading every line

line=" "

# This array stores all the weights of the horses

horse_weight=[]

# This array stores the type of the horses

horse_type=[]

while True:

    line=input()

    # The input loop breaks if there is an empty line

    if len(line)==0:

        break

    arr=line.split()

    # The first item when we split the input line is the weight of the horse

    horse_weight.append(int(arr[0]))

    # Then we find the first space and the words after that mention the type of the horse

    index=line.find(" ")

    horse_type.append(line[index+1:])

# For all the inputs in the array we print the amount of food needed

for i in range(len(horse_type)):

    print("{} {}".format(i+1,food_needed(horse_weight[i],horse_type[i])))



If there is any code then refer to the images given for the proper indentation of the code

Hope this helps
In case of any queries feel free to ask me in the comments section below
Happy Coding :) :)
Have a good day

Add a comment
Know the answer?
Add Answer to:
Problem 3: HorseWeights In C++ Please Research shows that horses are satisfied when they consume an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE ANSWER EACH QUESTION Tim is a 34-year-old computer programmer who is married with three children....

    PLEASE ANSWER EACH QUESTION Tim is a 34-year-old computer programmer who is married with three children. He was always a little overweight as a kid and young adult, but his weight has now become a health concern for him. Standing at 5 feet 8 inches, he weighs 280 pounds and looks “apple-shaped,” meaning that he carries a lot of the weight around his mid-section. According to his family doctor, he has high cholesterol levels, hypertension, type 2 diabetes, and sleep...

  • Can anyone help me with this nutrition homework? How many Calories did Bobby consume (note that...

    Can anyone help me with this nutrition homework? How many Calories did Bobby consume (note that digestible carbohydrate includes sugar grams)? A. 2030 B. 2550 C. 2887 D. 2982 E. 3525 Based upon Bobby's Calorie intake, Bobby's Dietary Reference Intake (DRI) for fiber is _____ grams. A. 25 B. 38 C. 40.4 D. 42 E. 54.5 Bobby consumed _____ percent of his Calories from sugar, and _____ the AMDR. 4.4, met 10,met 13,met 26, did not meet 32,didnotmeet Bobby consumed...

  • answer the questions based on the informations on the 3 pictures please: What are the essential...

    answer the questions based on the informations on the 3 pictures please: What are the essential responsibilities of a structural designer or engineer in designing a structure? What factors would you consider and why when planning the design of a building structure? You are the project team leader for the design of a single family house in southwest Houston area. Discuss the types of structural loads you think are important and explain why.​​​​​​​ d) Thermal load changes in perature cause...

  • FART I TRUE FALSE QUESTIONS (10 points). Please write True (1) or False (F) on the...

    FART I TRUE FALSE QUESTIONS (10 points). Please write True (1) or False (F) on the blank Scarcity is the intimited nature of society's resources given society's limited wants 2. A reward is a type of positive incentive. 3. To remove difficulty of double coincidence of wants we use money. 4. An exogenous factor is a variable that can be controlled for inside the model. 5. The PPF will not have a constant slope. 6. The law of demand states...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

  • 1. According to the paper, what does lactate dehydrogenase (LDH) do and what does it allow...

    1. According to the paper, what does lactate dehydrogenase (LDH) do and what does it allow to happen within the myofiber? (5 points) 2. According to the paper, what is the major disadvantage of relying on glycolysis during high-intensity exercise? (5 points) 3. Using Figure 1 in the paper, briefly describe the different sources of ATP production at 50% versus 90% AND explain whether you believe this depiction of ATP production applies to a Type IIX myofiber in a human....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT