Question: MSC 1 1 0 : Computer Programming 2 home > 3 . 1 6 : Application: Input Validation zyBooks catalog ( c ) jeanma 8
MSC : Computer Programming home : Application: Input Validation
zyBooks catalog
c jeanmaiStockphoto
Suppose you are charged with writing a program that processes rat weights. We don't know for sure how giant a rat could be but the New Guinea rats weighed no more than A regular house rat Rattus rattus weighs up to so we'll say that any weight was surely an input error, perhaps confusing grams and kilograms. Of course, inputs should be positive numbers. Rearrange the following lines of code to supply error handling. Not all lines are useful.
How to use this tool
Unused
else if weight
cout "Error: Weight must be positive" endl;
if cin.fail
else if cinfail
if cinfail
else
cout "Error: Not a number" endl;
else if weight
else if weight
int main
cout "Enter weight in : end l;
double weight;
cin weight;
#include
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
