Step 1: Examine the following main module from Lab 4.1. Notice that if the user
ID: 3599596 • Letter: S
Question
Step 1: Examine the following main module from Lab 4.1. Notice that if the user enters a capital 'Y' the program will end since the while loop only checks for a lower case 'y Module main) //step 1: Declare variables below Declare Integer tota1B ttle = 0 Declare Integer c unter- 1 Declare Integer toda vBottles = 0 Declare Re1 tot|payout Declare 3tring keepGoing = 'y, //step 3: Loop to run program again While keepGoing =.. 'y, //Step 2: Call functions al PavoutItotalBottles, totalPayout) printInfaltotalBottles, totalPayout) Display "Do you want to run the program gain? Enter y for yes or n for no)." Input keepGoing End While End Module Step 2: Write a line of code that will convert the input value to a lower case value. (See Validating String Input, Page 276). Step 3: Examine the getBottles module from the same program. Notice the potential input error of the user entering a negative value into todayBottles. Rewrite the module with an input validation loop inside the existing while loop that will verify that the entryExplanation / Answer
Step 2:
Input keepGoing
##Introduce the below piece of code in existing code
##The below piece of code will turn the entered string into lower cases
keepGoing=keepGoing.lower()
Step 3:
Input todayBottles
##Include the below piece of code in your program
##If is there to ensure that the value of variable todayBottles is greater than 0
if(todayBottles<=0):
##If the user enters a value less than 0 then run the while loop and ask for a positive value
##Continue with the while loop till the user enters a positive value for todayBottles
##Once the user enters a positive value break out of loop
while(todayBottles<=0):
print("Please enter a positive value of todayBottles")
Input todayBottles
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.