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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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

8.
TEST #1:
Welcome to Buddy's Average Sheep Age Calculator!
10.
11.
12.
9.
Enter in the sheep ages, input -1 to exit
Sheep Age: 8
Sheep Age: 12
13.
14.
15. *** Invalid sheep age
please input a value less than or equal to 9!
16.
17.
Sheep Age: 9
Sheep Age: 0
Sheep Age: 2
Sheep Age: 5
Sheep Age: 6
Sheep Age: -1
18.
19.
20.
21.
22.
23.
24.
On average your sheep are 5.0 years old!
In general, your sheep are MIDDLE-AGED!
25.
26.
27.
28.
29. TEST #2:
30. Welcome to Buddy's Average Sheep Age Calculator!
31.
32.
Enter in the sheep ages, input -1 to exit
33.
Sheep Age: 10
34.
35. *** Invalid sheep age
please input a value less than or equal to 9!
36.
37.
Sheep Age: 2
Sheep Age: 5
Sheep Age: 1
Sheep Age: 4
Sheep Age: 2
Sheep Age: 3
38.
39.
40.
41.
42.
Sheep Age: 0
Sheep Age: 7
Sheep Age: -9
43.
44.
45.
46.
47.
On average your sheep are 3.0 years old!
In general, your sheep are BABIES!
48.
49.
50.
Transcribed Image Text:8. TEST #1: Welcome to Buddy's Average Sheep Age Calculator! 10. 11. 12. 9. Enter in the sheep ages, input -1 to exit Sheep Age: 8 Sheep Age: 12 13. 14. 15. *** Invalid sheep age please input a value less than or equal to 9! 16. 17. Sheep Age: 9 Sheep Age: 0 Sheep Age: 2 Sheep Age: 5 Sheep Age: 6 Sheep Age: -1 18. 19. 20. 21. 22. 23. 24. On average your sheep are 5.0 years old! In general, your sheep are MIDDLE-AGED! 25. 26. 27. 28. 29. TEST #2: 30. Welcome to Buddy's Average Sheep Age Calculator! 31. 32. Enter in the sheep ages, input -1 to exit 33. Sheep Age: 10 34. 35. *** Invalid sheep age please input a value less than or equal to 9! 36. 37. Sheep Age: 2 Sheep Age: 5 Sheep Age: 1 Sheep Age: 4 Sheep Age: 2 Sheep Age: 3 38. 39. 40. 41. 42. Sheep Age: 0 Sheep Age: 7 Sheep Age: -9 43. 44. 45. 46. 47. On average your sheep are 3.0 years old! In general, your sheep are BABIES! 48. 49. 50.
52. TEST #3:
53. Welcome to Buddy's Average Sheep Age Calculator!
54.
55.
Enter in the sheep ages, input -1 to exit
56.
Sheep Age: 10
57.
58. *** Invalid sheep age
please input a value less than or equal to 9!
59.
60.
Sheep Age: 9
Sheep Age: 8
Sheep Age: 6
Sheep Age: 9
Sheep Age:
Sheep Age: 2
Sheep Age: 12
61.
62.
63.
64.
7
65.
66.
67.
68. *** Invalid sheep age
- please input a value less than or equal to 9!
69.
70.
Sheep Age: 9
Sheep Age: -5
71.
72.
73.
On average your sheep are 7.1 years old!
In general, your sheep are AGING
74.
- time to breed!
75.
76.
78. Thank you for using Buddy' s Average Sheep Age Calculator!
• LL
79. Have a great day!! :)
Transcribed Image Text:52. TEST #3: 53. Welcome to Buddy's Average Sheep Age Calculator! 54. 55. Enter in the sheep ages, input -1 to exit 56. Sheep Age: 10 57. 58. *** Invalid sheep age please input a value less than or equal to 9! 59. 60. Sheep Age: 9 Sheep Age: 8 Sheep Age: 6 Sheep Age: 9 Sheep Age: Sheep Age: 2 Sheep Age: 12 61. 62. 63. 64. 7 65. 66. 67. 68. *** Invalid sheep age - please input a value less than or equal to 9! 69. 70. Sheep Age: 9 Sheep Age: -5 71. 72. 73. On average your sheep are 7.1 years old! In general, your sheep are AGING 74. - time to breed! 75. 76. 78. Thank you for using Buddy' s Average Sheep Age Calculator! • LL 79. Have a great day!! :)
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY