What does the phrase “garbage in, garbage out” mean? Refer to the section of you
ID: 3814753 • Letter: W
Question
What does the phrase “garbage in, garbage out” mean? Refer to the section of your textbook defining an input validation loop in chapter 7. Using the 7.2 Input Validation Loop example, modify the following pseudocode validation loop to check for negative wholesale cost as well as a maximum wholesale cost not to exceed $50.00.
28 // Validate the wholesale cost.
29 While wholesale < 0
30 Display "The cost cannot be negative. Please"
31 Display "enter the correct wholesale cost."
32 Input wholesale
33 End While
Explanation / Answer
The Phrase "garbage in, garbage out" means that the quality of output of a program depends on the quality of input. If we provide incorrect input to the program then the output of the program will be incorrect generally.
Modified pseudocode:
while( (wholesale < 0) or (wholesale > 50) ):
if(wholesale < 0):
Display(The cost cannot be negative.Please enter the correct wholesale cost);
Input wholesale
else if():
Display(The cost cannot be more than $50.Please enter the correct wholesale cost);
Input wholesale
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.