Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Write a Python code

This lab requires you to write a complete program using a condition controlled loop, a counter controlled loop, and an accumulator. The program is as follows:

Write a program that will allow a grocery store to keep track of the total number of bottles collected for seven days.

The program will calculate the total number of bottles returned for the week and the amount paid out (the total returned times .10 cents).

The output of the program should include the total number of bottles returned and the total paid out.

The program will ask the user if they have more data to enter and will end the program if they do not.

Step 1: In the pseudocode below, declare the following variables under the documentation for Step 1.

  • A variable called totalBottles that is initialized to 0
    • This variable will store the accumulated bottle values
  • A variable called counter and that is initialized to 1
    • This variable will control the loop
  • A variable called todayBottles that is initialized to 0
    • This variable will store the number of bottles returned on a day
  • A variable called totalPayout that is initialized to 0
    • This variable will store the calculated value of totalBottles times .10
  • A variable called keepGoing that is initialized to "y"
    • This variable will be used to run the program again

Step 2: In the pseudocode below, make calls to the following functions under the documentation for Step 2.

  • A function call to getBottles that returns the total number of bottles for the week.
  • A function called calcPayout that passes totalPayout and It returns the total payout for the week.
  • A module called printInfo that passes totalBottles and

Step 3: In the pseudocode below, write a condition controlled while loop around your function calls using the keepGoing variable under the documentation for Step 3.

Complete Steps 1-3 below:

Module main ()

// Step 1: Declare variables below

___________________________________________________

___________________________________________________

___________________________________________________

___________________________________________________

___________________________________________________

// Step 3: Loop to run program again

While _________________________________

// Step 2: Call functions

totalBottles = _________________________________

totalPayout = _________________________________

________________________________________________

Display "Do you want to enter another week’s worth of data?"

Display "(Enter y or n)"

Input _________________________________

End While

End Module

Step 4: In the pseudocode below, write the missing lines, including:

  1. The 3 missing variable declarations and initializing them to 0
  2. The missing condition (Hint: should run seven iterations)
  3. The missing input variable
  4. The missing accumulator
  5. The increment statement for the counter
  6. The missing return statement

// getBottles function

Function getBottles()

NBR_OF_DAYS = 7

// Declare and initialize totalBottles, todayBottles, counter to 0

  1. ___________________________________

___________________________________

___________________________________

While b._______________________________

Display "Enter number of bottles returned for day #",

counter, ":"

Input c.______________________________

  1. ___________________________________
  2. ___________________________________

End While

Return f._______________________________

End Function

Step 5: In the pseudocode below, write the missing lines, including:

  1. The missing parameter list
  2. The missing calculation
  3. The missing return statement

// calcPayout function

Function Real calcPayout(a.______________________)

PAYOUT_PER_BOTTLE = .10

totalPayout = 0 // resets to 0 for multiple runs

  1. ______________________________

Return c._________________________

End Function

Step 6: In the pseudocode below, write the missing lines, including:

  1. The missing parameter list
  2. The missing display statement
  3. The missing display statement

// printInfo module

Module printInfo(a.______________________________________)

  1. _______________________________________________
  2. _______________________________________________

End Module

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education