Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below is the my course project that I have to do for my class, this is just to g

ID: 3664185 • Letter: B

Question

Below is the my course project that I have to do for my class, this is just to give you the information behind what exactly I am asking. At the very bottom is the code I have for it, I am looking for some assistance in figuring out exactly why the code is not working correctly ( why it doesn't act like the instructions like the problem statement wants it to) and I am hoping for some adjustments from anyone willing to help. thank you for your time and understanding.

The project is to create a newspaper dispenser that works on the adafruit lcd screen that is attached to the raspberry pi. I have to create this code on python idle program version 2.7.5. The display starts off with showing a welcome message saying “Today's Paper Only 30 Cents.

Each time a coin is inserted, the LCD displays the total amount deposited: “Total: $XX.” When a minimum of 30 cents is inserted, the program will cycle between two screens. The first screen will indicate the total amount deposited: “Total: $XX.” This is displayed on the top line and the amount of change available (“Change: $XX”) is displayed on the second line. The second screen will display “Enjoy” on the first line and “Your Paper” on the second line in green backlight.

Nickels, dimes, and quarters are represented by the switches on the Adafruit. If the left button is pressed, a nickel is recorded; if the right button is pressed, the controller records a dime; and if the down button is pressed, a quarter is recorded. Displaying the Running Total As soon as the first switch is pressed (coin entered) the LCD displays the total amount entered. If Nickel is pressed, the screen below is displayed. Note the leading zero.

The program keeps a running total of the amount entered and displays the total amount deposited after each switch is pressed (coin is entered). If Dime is now pressed, the LCD will show the screen below. This process continues until the minimum amount of 30 cents is entered.

Displaying the Total and Change

The focus of this portion of the project is to count and display the change amount that would be refunded along with the total amount inserted. The change amount is displayed on the bottom row of the LCD. Keep in mind the price of the newspaper is 30 cents. The display must look like the following.

Enjoy (ON THE FIRST LINE)

Your Paper (ON THE SECOND LINE)

Develop “Door Open” Indication Function When the adequate change has been entered, the Total and Change screen is displayed for 1 second and the message reading “Enjoy Your Paper” is displayed for 1 second (with a green backlight0. The display must look like the following. Enjoy (ON THE FIRST LINE) Your Paper (ON THE SECOND LINE) The program returns to the beginning and displays the initial screen. Today's Paper (FIRST LINE) Only 30 Cents (SECOND LINE)

SOURCE CODE:

#!/usr/bin/python

from time import time

from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate

# Adafruit object

LCD_disp = Adafruit_CharLCDPlate()

# declare the required variables

Inp_NICKEL = 5

Inp_DIME = 10

Inp_QUARTER = 25

tot = 0

# method to print the total

def print_total():

LCD_disp.clear()

LCD_disp.message(' Total: $.')

LCD_disp.message(tot)

# loop code to continuously process input

while (tot<=30):

# code to represent switches on the Adafruit LCD

LCD_disp.message("Today’s Paper/nOnly 30 Cents.")

if LCD_disp.buttonPressed(LCD_disp.LEFT):

tot = tot + Inp_NICKEL

print_total()

sleep(1)

if LCD_disp.buttonPressed(LCD_disp.RIGHT):

tot = tot + Inp_DIME

print_total()

sleep(1)

if LCD_disp.buttonPressed(LCD_disp.DOWN):

tot = tot + Inp_QUARTER

print_total()

sleep(1)

LCD_disp.message('Enjoy')

LCD_disp.message('Your Paper')

Explanation / Answer

Changes in the code as well as code for displaying change is highlighted in bold. Please refer:

#!/usr/bin/python

from time import time

from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate

# Adafruit object

LCD_disp = Adafruit_CharLCDPlate()

# declare the required variables

Inp_NICKEL = 5

Inp_DIME = 10

Inp_QUARTER = 25

tot = 0

# method to print the total

def print_total():

    LCD_disp.clear()

LCD_disp.message(' Total: $.')

LCD_disp.message(tot)

# loop code to continuously process input

while (tot<30):

# code to represent switches on the Adafruit LCD

    LCD_disp.message("Today’s Paper/nOnly 30 Cents.")

if LCD_disp.buttonPressed(LCD_disp.LEFT):

    tot = tot + Inp_NICKEL

print_total()

sleep(1)

if LCD_disp.buttonPressed(LCD_disp.RIGHT):

    tot = tot + Inp_DIME

print_total()

sleep(1)

if LCD_disp.buttonPressed(LCD_disp.DOWN):

    tot = tot + Inp_QUARTER

print_total()

sleep(1)

# Print the total and change when total equal to exact 30
if tot == 30
   change = 0
   LCD_disp.message(' Total: $.')

   LCD_disp.message(tot)

   LCD_disp.message(' Change: $.')

   LCD_disp.message(change)
  
# Print the total and change when total is greater than 30  
if tot > 30
   change = tot - 30
   LCD_disp.message(' Total: $.')

   LCD_disp.message(tot)

   LCD_disp.message(' Change: $.')

   LCD_disp.message(change)


LCD_disp.message('Enjoy')

LCD_disp.message('Your Paper')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote