Saint Louis University |
Computer Science 1300
|
Computer Science Department |
Please make sure you adhere to the policies on academic integrity.
Write a program that asks a user for a weight in pounds (possibly fractional), and outputs the weight in kilograms. (For the record, 1 pound equals approximately 0.45359 kilograms.)
Your program should ensure that the user correctly entered a nonnegative numeric value as input. As sample session might appear as follows
Enter a weight in pounds: no That is not a valid number. Enter a weight in pounds: -5.3 Weights must be nonnegative. Enter a weight in pounds: 2.5 That is equal to 1.13398 kilograms.
Assume that we are writing a function
Give an implementation of such a function that rigorously checks that the parameters adhere to these expectations. (Once you've performed the parameter-checking, you don't need to do anything within the function body.)