Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Include your name, student number, and lab section as a comment at the top of each of your files. 2 Develop a function called

image text in transcribed
1 Include your name, student number, and lab section as a comment at the top of each of your files. 2 Develop a function called averageAge which takes the number of campers (how many) as a parameter. The function must ask the user to enter an age for each camper and then returns the average of those ages as a float value. Each age is an int value. You can assume that the user always enters a valid (age greater than 0 - no checking necessary) The average age for the campers should not be printed in this function. 3. Develop a main program that asks the user how many campers are at the camp and then passes that value to the function. The program then displays the average age for the camp from the ages entered by the user The program must repeatedly ask how many campers are in the camp passing the value to the function and displaying the average age for the camp until the user enters a value 0 or less for the number of campers at which point the program terminates Be sure to format the average age for the camp as a number with 1 decimal place. How many campers are at the camp? 4 Please enter an age: 12 Please enter an age: 17 Please enter an age: 13 Please enter an age: 16 The average age of the campers is 14.5. How many campers are at the camp? 1 Please enter an age: 15 The average age of the campers is 15.0. How many campers are at the camp? 2 Please enter an age: 12 Please enter an age: 11 The average age of the campers is 11.5. How many campers are at the camp? 0 4 Use appropriate camel case variable names and proper tab indentation in your program If you cannot do everything, do as much as possible. Part marks will be assigned for incomplete programs (see marking scheme below). Keep saving your program. DO YOUR OWN WORKI When you have finished, save your program as lab_test2.c. Submit the program electronically on the Blackboard. Marking Scheme Correct program structure 1 Correct use of variables main() function 3.5 averageAge() function 45 5:25 AM E 12/7/2021

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions