Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to add Python code to where it will stop and prompt that there is an invalid input. Where do I put that at

I need to add Python code to where it will stop and prompt that there is an invalid input. Where do I put that at in the code?image text in transcribed

3 main.py import locale # Cash Register class class CashRegister: # init constructor def __init__(self): self.numItems = 0 self.totalPrice = 0 # Method addItem takes cost as input # and add the cost to the total and # increment the numItems by 1 def addItem( self, cost): # increment numItems by 1 self.numItems = self.numItems + 1 # add cost to total self.totalPrice = self.totalPrice + cost e e def getTotall self ): return self.totalPrice def getCount( self): return self.numItems # main method #def main(): # set quit to -1 quit = -1 # create an instance of CashRegister class) register = CashRegister() print('___Welcome!_ ') cost = float(input('Enter cost of item or -1 to quit: ')); while quit != cost: register.addItem(cost) cost = float(input('Enter cost of item or -1 to quit: ')); locale.set locale( locale. LC_ALL, 'en_US') print('Total number of items in cart: ', register.getCount()) print('Total cost: ', locale.currency (register.getTotal(), grouping=True)), if __name__ = '_main__

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What steps should be taken to address any undesirable phenomena?

Answered: 1 week ago