IRobson1112

Untitled

Jan 15th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.35 KB | None | 0 0
  1. #Ian and Maurice
  2. import random #imports the random function
  3. import math #imports the math function
  4. balance=1000 #The amount of money they start with
  5. balance=int(balance)
  6. tax=0# the amount of original tax
  7. tax=int(tax)
  8. shipping=0# the amount of original shipping
  9. shipping=int(shipping)
  10. def user_pass():
  11.     print"Hey! Welcome to the PC parts store!"
  12.     allowed_users=['ADMIN']# the username
  13.     allowed_password=['admin']# the password
  14.     username_password=raw_input("What is your username:")#asks for their username
  15.     if username_password in allowed_users: #checks if username is there
  16.         print"Great" #username woorks
  17.     else:
  18.         print "Access denied"#username does not work
  19.         exit()
  20.     password=raw_input("What is your password?") #if username is correct, asks password
  21.     if password in allowed_password:#checks if their password is in the allowed passwrods
  22.         print"Access granted"#password works
  23.     else:
  24.         print"Access denied"#password does not work
  25.         exit()
  26. user_pass()      
  27. def shop():
  28.     global shipping #global for all the original functions that where said in the beging
  29.     global balance
  30.     global tax
  31.     print"What would you like to do: Buy or Leave"#asks is they want to stay
  32.     product=raw_input(">")
  33.     if product=="Leave":# if they put leave they go
  34.         print"Good Bye"
  35.         exit()
  36.     if product=="Buy":# if they say buy goes on
  37.         print"Ok here is our inventory, and you have $1,000" #This is the inventory and shows the user what we have to buy and how much it costs
  38.         print"1. Razer Blackwidow Chroma keyboard: $169.99"
  39.         print"2. Razer Taipan Mouse: $79.99"
  40.         print"3. Acer G226HQL 21.5-Inch Screen LED Monitor: $89.99"
  41.         print"4. MSI 970 GAMING DDR3 2133 ATX AMD Motherboard: $99.99"
  42.         print"5. Kingston ValueRAM 2GB Kit (2x1GB Modules): $19:46"
  43.         print"6. PNY GeForce GT 730 2GB DDR3 Graphics Card: $59.99"
  44.         print"7. Coolerguys PRO-Metal Series Dual 80mm Cooling kit with Preset Thermal Controller: $60.00"
  45.         print"8. Thermaltake Commander MS-I Epic Edition VN400A1W2N-B No PS Mid Tower Case (Black/Red): $53.98"
  46.         print"9. Lenovo Lenovo 300 GB Internal hard drive SAS 6Gb/s 2.5: $202.50"
  47.         print"10. Cisco Approved MEM-FD4G - 4gb Compact Flash Disk PCMCIA for Cisco 12000 Series: $89.99"
  48.         while balance>27.85: #the amount that is needed including tax to buy anything else
  49.             buy=raw_input("Here is what we got, what would you like to buy:")
  50.             if buy=='1'and balance > 188.89:#the amount required to buy the item, including tax and shipping
  51.                 balance-=169.99+(169.99*.07)+7#the shipping, the tax and original price all put together
  52.                 tax+=169.99*.07#the tax
  53.                 shipping+=73#the shipping
  54.                 print"The price of the item is $169.99." #This shows thw user cost of item and tax and shipping cost and it is repeated multiple times
  55.                 print"The tax is $11.89."
  56.                 print"The shipping cost is $7.00."
  57.                 print"That will be $188.89 "
  58.                 print"You have $%d left"%balance
  59.                 print"Your transaction ID is:"
  60.                 from random import choice#imporat a choice for the computer
  61.                 from string import ascii_uppercase#only using uppercase
  62.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))#the range for hte ID
  63.             elif buy=='2'and balance>92.59:#repeated
  64.                 balance-=79.99+(79.99*.07)+7
  65.                 tax+=79.99*.07
  66.                 shipping+=7
  67.                 print"The price of the item is $79.99."
  68.                 print"The tax is $5.90."
  69.                 print"The shipping cost is $7.00."
  70.                 print"That will be $92.59"
  71.                 print"You have $%d left"%balance
  72.                 print"Your transaction ID is:"
  73.                 from random import choice
  74.                 from string import ascii_uppercase
  75.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  76.             elif buy=='3'and balance>103.29: #repeated
  77.                 balance-=89.99+(89.99*.07)+7
  78.                 tax+=89.99*.07
  79.                 shipping+=7
  80.                 print"The price of the item is $89.99."
  81.                 print"The tax is $6.30."
  82.                 print"The shipping cost is $7.00."
  83.                 print"That will be $103.29"
  84.                 print"You have $%d left"%balance
  85.                 print"Your transaction ID is:"
  86.                 from random import choice
  87.                 from string import ascii_uppercase
  88.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  89.             elif buy=='4'and balance>113.99:#repeated
  90.                 balance-=99.99+(99.99*.07)+7
  91.                 tax+=99.99*.07
  92.                 shipping+=7
  93.                 print"The price of the item is $99.99."
  94.                 print"The tax is $7.00."
  95.                 print"The shipping cost is $7.00."
  96.                 print"That will be $113.99"
  97.                 print"You have $%d left"%balance
  98.                 print"Your transaction ID is:"
  99.                 from random import choice
  100.                 from string import ascii_uppercase
  101.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  102.             elif buy=='5'and balance > 27.85:#repeated
  103.                 balance-=19.49+(19.49*.07)+7
  104.                 tax+=19.49*.07
  105.                 shipping+=7
  106.                 print"The price of the item is $99.99."
  107.                 print"The tax is $1.36"
  108.                 print"The shipping cost is $7.00."
  109.                 print"That will be $27.85"
  110.                 print"You have $%d left"%balance
  111.                 print"Your transaction ID is:"
  112.                 from random import choice
  113.                 from string import ascii_uppercase
  114.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  115.             elif buy=='6'and balance>71.19:#repeated
  116.                 balance-=59.99+(59.99*.07)+7
  117.                 tax+=59.99*.07
  118.                 shipping+=7
  119.                 print"The price of the item is $59.99."
  120.                 print"The tax is $4.20"
  121.                 print"The shipping cost is $7.00."
  122.                 print"That will be $71.19"
  123.                 print"You have $%d left"%balance
  124.                 print"Your transaction ID is:"
  125.                 from random import choice
  126.                 from string import ascii_uppercase
  127.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  128.             elif buy=='7'and balance>71.20:#repeated
  129.                 balance-=60.00+(60.00*.07)+7
  130.                 tax+=60.00*.07
  131.                 shipping+=7
  132.                 print"The price of the item is $60.00."
  133.                 print"The tax is $4.20"
  134.                 print"The shipping cost is $7.00."
  135.                 print"That will be $71.20"
  136.                 print"You have $%d left"%balance
  137.                 print"Your transaction ID is:"
  138.                 from random import choice
  139.                 from string import ascii_uppercase
  140.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  141.             elif buy=='8'and balance>64.76:#repeated
  142.                 balance-=53.98+(53.98*.07)+7
  143.                 tax+=53.98*.07
  144.                 shipping+=7
  145.                 print"The price of the item is $53.98."
  146.                 print"The tax is $3.78"
  147.                 print"The shipping cost is $7.00."
  148.                 print"That will be $64.76"
  149.                 print"You have $%d left"%balance
  150.                 print"Your transaction ID is:"
  151.                 from random import choice
  152.                 from string import ascii_uppercase
  153.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  154.             elif buy=='9'and balance>223.66:#repeated
  155.                 balance-=202.50+(202.50*.07)+7
  156.                 tax+=202.50*.07
  157.                 shipping+=7
  158.                 print"The price of the item is $202.50."
  159.                 print"The tax is $14.18"
  160.                 print"The shipping cost is $7.00."
  161.                 print"That will be $223.66"
  162.                 print"You have $%d left"%balance
  163.                 print"Your transaction ID is:"
  164.                 from random import choice  
  165.                 from string import ascii_uppercase
  166.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  167.             elif buy=='10'and balance>103.29:#repeated
  168.                 balance-=89.99+(89.99*.07)+7
  169.                 tax+= 89.99*.07
  170.                 shipping+=7
  171.                 print"The price of the item is $89.99."
  172.                 print"The tax is $6.30"
  173.                 print"The shipping cost is $7.00."
  174.                 print"That will be $103.29"
  175.                 print"You have $%d left"%balance
  176.                 print"Your transaction ID is:"
  177.                 from random import choice
  178.                 from string import ascii_uppercase
  179.                 print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  180.             else:
  181.                 print"Good bye"
  182.                 print"You have $%d and thanks for shopping with us and have a good day."%balance #Tells the user their balance
  183.                 exit() #Exits the code
  184. shop()
Add Comment
Please, Sign In to add comment