Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this Assignment will attach ONE file, your program file (the .cpp file). DO NOT cut and paste your code into the Add Comments section

For this Assignment will attach ONE file, your program file (the .cpp file). DO NOT cut and paste your code into the Add Comments section of the Assignment or email your program, your program will NOT be graded and you will receive a zero for the assignment.

If program does not compile you will automatically lose -10.

PROBLEM: Hospital Baby Weights. (20 pts)

Write program that allows you to enter five baby weights. Your program will determine which baby's weight was the lowest, which was the highest and what the average baby's weight was. Your program MUST validate the baby's weight (see Input Validation below). If there is a Tie for the lowest birth or highest birth weight then display a message saying that there is no lowest or highest for Today.

Input Validation: The program must check to see if the user enters a valid baby weight. A number greater than zero must be entered. If the user does not enter a valid value, display an error message and continue to ask the user to enter the value again until a valid value is entered.

SAMPLE OUTPUT:

COP2000 HOMEWORK ASSIGNMENT 5B 1

Homework Assignment 5 Pool

PSEUDO-CODE for main function:

  1. Declare and Initialize Variables to Store Baby Weights and Average
  2. Call welcome() to display the program description
  3. Call getBabyWeight () for baby1
  4. Call getBabyWeight () for baby2
  5. Call getBabyWeight () for baby3
  6. Call getBabyWeight () for baby4

COP2000 HOMEWORK ASSIGNMENT 5B 2

Homework Assignment 5 Pool

  1. Call getBabyWeight () for baby5
  2. Call findLowest (baby1, baby2, baby3, baby4, baby5)
  3. Call findHighest(baby1, baby2, baby3, baby4, baby5)
  4. Call weightAverage (baby1, baby2, baby3, baby4, baby5) - Don't forget to capture the
  5. returned value
  6. Output the Average Baby Weight

CONSTRAINTS:

  • NO GLOBAL VARIABLES ALLOWED. (Automatic -10)
  • You must use: int main()
  • No Arrays or Vectors
  • The program must use local variables. (2 pts)
  • All functions MUST be called by main. (3 pts)
  • Output must be formatted properly and correct. (3 pts)
  • Include a comment at the beginning of the program stating the purpose of the program,
  • your name, the date, and your class (1pt is for code organization and use of whitespace).
  • (3 pts)
  • This program MUST use the following functions: (9 pts)
  • NAME YOUR FUNCTIONS AS SHOWN BELOW (- 10 if not named correctly ):
  • void getBabyWeight(double &) - (2 pts) is passed the weight of the baby by reference. This function must ask the user for the baby's weight. You must validate the input for baby's weight (See Input Validation above). This function returns no value.
  • void findLowest (double, double , double , double, double) - (2 pts) is passed the five baby weights and finds the lowest weight and displays this value. The output must be formatted properly.
  • void findHighest (double, double , double , double, double) - (2 pts) is passed the five baby's weights and finds the highest weight and displays this value. The output must be formatted properly.
  • void welcome() - (1 pts) is NOT passed any values and returns no value. This function outputs a description of the program and the developer's name (i.e. YOUR name). Your function MUST display the following text and fill in your name as the developer's name (i.e. replace "PUT YOUR NAME HERE" with your name).

COP2000 HOMEWORK ASSIGNMENT 5B 3

Homework Assignment 5 Pool

****************************************************************** BABY WEIGHT PROGRAM

Please Enter the Five Baby Weights

Please enter a real number Weights (Must be > 0).

Program Developed by: "PUT YOUR NAME HERE" *****************************************************************

double weightAverage(double , double , double, double, double) - (2 pts) The five baby weights are passed to this function and the function averages the weights, the average calculation is then RETURNED to main. The average result is then OUPUT in the main function.

WRITE THE PROGRAM:

Write the program according to your Algorithm or Pseudo Code for the Problem above. CHECK THE PROGRAM:

  • Does the program meet the Constraints stated above?
  • Is the program displaying the correct output?
  • Is the program formatted correctly?

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_2

Step: 3

blur-text-image_3

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions