-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitignore
More file actions
39 lines (34 loc) · 1.21 KB
/
.gitignore
File metadata and controls
39 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# DSC 510
# Week 11
# Programming Assignment Week 11
# Author Joseph Madden
# 11/07/2022
# The purpose of this program is to have a loop which allows the user to continue to add items to cart.
# class CashRegister :
def __init__('self, total = 0.0, items = 0.0)
self.total = total
self.items - items
def AddItem('self, amount'):
'self'.items = 'self'.('items') + 1
'self'.total = 'self'.('total') + 'amount'
def 'GetTotal'(self):
return self.total
def 'GetCount'(self):
return self.items
def main():
'testtrans' = 'CashRegister'(0,0)
while True:
try:
price = float(input("Please enter the price of your item(s). Enter -1 to quit "))
if price > 0:
'testtrans'.AddItem(price)
elif price < -1:
print("Please enter a valid value. Enter the price of your item or -1 to quit")
except ValueError:
print('Please enter a valid value. Enter the price of your item or -1 to quit')
finally:
if 'price' == -1:
print("Your total cost is :$", round('testtrans'.GetTotal,2))
print("Your total items purchased : ",'testtrans'.GetTotal,)
break
# main()