rite a program to help Buddy (the sheepdog) calculate the average age of all his sheep. The program will accept as many ages as Buddy needs to input. The program should help Buddy minimize input errors by error-checking the age for him (everybody knows the maximum age for cartoon sheep is 9 years old). When Buddy’s sheep start to get old, he needs to breed more sheep. So, the code should also let Buddy know if the average age indicates if his sheep are aging, young, or middle-aged based on the chart below: Average Sheep Age Population is… <= 3 Young 4 - 6 Middle-aged > 6 Aging Using the appropriate loop, the code should execute 3 test runs (see output for specifics). • use strncpy to store the output for the maturity of the sheep. Think about which loop to run for one Test Run (i.e. the primary loop) 2 - Think of which loop to run so it executes 3 test runs (auxiliary loop) 3 – Write one section at a time and test each section thoroughly as you go (incrementally). Output needs to look like the images below
Write a program to help Buddy (the sheepdog) calculate the average age of all his sheep. The
program will accept as many ages as Buddy needs to input. The program should help Buddy
minimize input errors by error-checking the age for him (everybody knows the maximum age for
cartoon sheep is 9 years old). When Buddy’s sheep start to get old, he needs to breed more
sheep. So, the code should also let Buddy know if the average age indicates if his sheep are aging,
young, or middle-aged based on the chart below:
Average Sheep Age Population is…
<= 3 Young
4 - 6 Middle-aged
> 6 Aging
Using the appropriate loop, the code should execute 3 test runs (see output for specifics).
• use strncpy to store the output for the maturity of the sheep.
Think about which loop to run for one Test Run (i.e. the primary loop)
2 - Think of which loop to run so it executes 3 test runs (auxiliary loop)
3 – Write one section at a time and test each section thoroughly as you go (incrementally).
Output needs to look like the images below
Step by step
Solved in 4 steps with 3 images