Answered step by step
Verified Expert Solution
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?
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started