Advertisement
Guest User

ijoij

a guest
Jul 29th, 2019
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Starting program...
  2. #Importing time module for title screen:
  3. import time
  4. import sys
  5.  
  6. #Define some variables
  7. a1= 0
  8. a2= 0
  9.  
  10. #Making 'on' and 'off' switches for result outputs:
  11. Result_2= 0
  12. Result_3= 0
  13.  
  14. #Title screen:
  15. #Made up of 0.1 sec delays and layers of text 'stacked' on eachother
  16. print('/$$$$$$$                /$$                    /$$           /$$$$$$$            /$$    /$$')
  17. time.sleep(0.1)
  18. print('| $$__  $$              | $$                   | $$          | $$__  $$          | $$   | $$')
  19. time.sleep(0.1)
  20. print('| $$  \ $$/$$   /$$ /$$$$$$$ /$$$$$$  /$$$$$$ /$$$$$$        | $$  \ $$/$$   /$$/$$$$$$ | $$$$$$$  /$$$$$$ /$$$$$$$')
  21. time.sleep(0.1)
  22. print('| $$$$$$$| $$  | $$/$$__  $$/$$__  $$/$$__  $|_  $$_/        | $$$$$$$| $$  | $|_  $$_/ | $$__  $$/$$__  $| $$__  $$')
  23. time.sleep(0.1)
  24. print('| $$__  $| $$  | $| $$  | $| $$  \ $| $$$$$$$$ | $$          | $$____/| $$  | $$ | $$   | $$  \ $| $$  \ $| $$  \ $$')
  25. time.sleep(0.1)
  26. print('| $$  \ $| $$  | $| $$  | $| $$  | $| $$_____/ | $$ /$$      | $$     | $$  | $$ | $$ /$| $$  | $| $$  | $| $$  | $$')
  27. time.sleep(0.1)
  28. print('| $$$$$$$|  $$$$$$|  $$$$$$|  $$$$$$|  $$$$$$$ |  $$$$/      | $$     |  $$$$$$$ |  $$$$| $$  | $|  $$$$$$| $$  | $$')
  29. time.sleep(0.1)
  30. print('|_______/ \______/ \_______/\____  $$\_______/  \___/        |__/      \____  $$  \___/ |__/  |__/\______/|__/  |__/')
  31. time.sleep(0.1)
  32. print('                            /$$  \ $$                                  /$$  | $$')
  33. time.sleep(0.1)
  34. print('                           |  $$$$$$/                                 |  $$$$$$/')
  35. time.sleep(0.1)
  36. print('                            \______/                                   \______/')
  37.  
  38. print('')
  39. print('_________________________________________________________')
  40. print('IF YOU WISH TO EXIT THE PROGRAM AT ANY TIME PRESS CTRL+C')
  41. print('---------------------------------------------------------')
  42. print('')
  43. input('[BEGIN?]') #Makeshift 'Begin' button
  44.  
  45. while True:
  46.   print('')
  47.   print('[ITEM A COST]') #Code Subheading
  48.  
  49.   #Start Infinite loop
  50.   while True:
  51.     try:
  52.       #Input prompt
  53.       temp_a1= float(input("What is the cost of item [a]: $")) #Save input float as 'temporary'
  54.     except ValueError: #Error exception:
  55.       print('')
  56.       #Error prompt
  57.       print('Please Enter a Number')
  58.       #Returns to start of the loop
  59.     else:
  60.       #Code is parsed
  61.       break
  62.       #Break and exit loop
  63.  
  64.   #Start Infinite loop
  65.   while True:
  66.     #Input prompt
  67.     discount1= input("Does item [a] have a discount? (y/n): ")
  68.     #'y' or 'n' Input
  69.     if discount1 == 'y' or discount1 == 'n':
  70.       #Code is parsed
  71.       break
  72.       #Break and exit loop
  73.     else:
  74.       print('')
  75.       #Error prompt
  76.       print('Please type in "y" to answer "Yes" and type in "n" to answer "No"')
  77.  
  78.   if discount1 == 'n': #Inputted 'n'
  79.     a1= temp_a1 #Make temporary value 'real' value
  80.  
  81.   if discount1 == 'y': #Inputted 'y'
  82.     print('')
  83.     print('[ITEM A DISCOUNT]') #Code Subheading
  84.     #Input prompt
  85.     q1 = input("Is the discount for item [a] percentage or a 'before and after' discount? (%/$): ")
  86.     #'%' or '$' Input
  87.  
  88.     if q1 == '%': #Inputted '%'
  89.       #Start Infinite loop
  90.       while True:
  91.         try:
  92.           #input prompt
  93.           p1= float(input('What is the percentage discount?: %')) #Input float for percentage discount
  94.         except ValueError: #Error exception:
  95.           print('')
  96.           #Error prompt
  97.           print('Please Enter a Number from 0-100')
  98.         if p1 > 100 or p1 < 0: #Incorrect input
  99.           print('')
  100.           #Error prompt
  101.           print('Please Enter a Number from 0-100')
  102.         else:
  103.           d1= (p1/100)*temp_a1 #Divide inputted percentage by 100 and multiply by item price to find discount amount
  104.           a1= temp_a1-d1 #Take discount from inputted price to get actual price
  105.           Result_3= 1 #Allows output for result 3
  106.           Result_2= 1 #Allows output for result 2
  107.           #Rounding values
  108.           d1= round(d1, 2)
  109.           a1= round(a1, 2)
  110.           print('You have saved $' + str(d1))
  111.           print('Item [a] is now $' + str(a1))
  112.           break
  113.           #Break and exit loop
  114.  
  115.     if q1 == '$': #Inputted '$'
  116.       #Start Infinite loop
  117.       while True:
  118.         try:
  119.           #input prompt
  120.           b4_price1= float(input('What was the price of item [a] before the discount?: $')) #Input float for before price
  121.         except ValueError:
  122.           print('')
  123.           print('Please Enter a Number')
  124.         else:
  125.           break
  126.       while True:
  127.         try:
  128.           #input prompt
  129.           after_price1= float(input('What was the price of item [a] after the discount?: $')) #Input float for after price
  130.         except ValueError: #Error exception:
  131.           print('')
  132.           #Error prompt
  133.           print('Please Enter a Number')
  134.         else:
  135.           break
  136.           #Break and exit loop
  137.       temp_a1= a1
  138.       #Rounding values
  139.       a1= round(a1, 2)
  140.       p1= (after_price1/b4_price1)*100
  141.       d1= after_price1-b4_price1
  142.       d1= round(d1, 2)
  143.       print('The percentage discount on item [a] is %' + str(round(p1, 2)))
  144.  
  145.  
  146.   print('')
  147.   print('[ITEM B COST]') #Code Subheading
  148.  
  149.   #Start Infinite loop
  150.   while True:
  151.     try:
  152.       #Input prompt
  153.       temp_a2= float(input("What is the cost of item [b]: $")) #Save input float as 'temporary'
  154.     except ValueError: #Error exception:
  155.       print('')
  156.       #Error prompt
  157.       print('Please Enter a Number')
  158.       #Returns to start of the loop
  159.     else:
  160.       #Code is parsed
  161.       break
  162.       #Break and exit loop
  163.  
  164.   #Start Infinite loop
  165.   while True:
  166.     #Input prompt
  167.     discount2= input("Does item [b] have a discount? (y/n): ")
  168.     #'y' or 'n' Input
  169.     if discount2 == 'y' or discount2 == 'n':
  170.       #Code is parsed
  171.       break
  172.       #Break and exit loop
  173.     else:
  174.       print('')
  175.       #Error prompt
  176.       print('Please type in "y" to answer "Yes" and type in "n" to answer "No"')
  177.  
  178.   if discount2 == 'n': #Inputted 'n'
  179.     a2= temp_a2 #Make temporary value 'real' value
  180.  
  181.   if discount2 == 'y': #Inputted 'y'
  182.     print('')
  183.     print('[ITEM B DISCOUNT]') #Code Subheading
  184.     #Input prompt
  185.     q2 = input("Is the discount for item [b] percentage or a 'before and after' discount? (%/$): ")
  186.     #'%' or '$' Input
  187.  
  188.     if q2 == '%': #Inputted '%'
  189.       #Start Infinite loop
  190.       while True:
  191.         try:
  192.           #input prompt
  193.           p2= float(input('What is the percentage discount?: %')) #Input float for percentage discount
  194.         except ValueError: #Error exception:
  195.           print('')
  196.           #Error prompt
  197.           print('Please Enter a Number from 0-100')
  198.         if p2 > 100 or p2 < 0: #Incorrect input
  199.           print('')
  200.           #Error prompt
  201.           print('Please Enter a Number from 0-100')
  202.         else:
  203.           d2= (p2/100)*temp_a2 #Divide inputted percentage by 100 and multiply by item price to find discount amount
  204.           a2= temp_a2-d2 #Take discount from inputted price to get actual price
  205.           Result_3= 1 #Allows output for result 3
  206.           Result_2= 1 #Allows output for result 2
  207.           #Rounding values
  208.           d2= round(d2, 2)
  209.           a2= round(a2, 2)
  210.           print('You have saved $' + str(d2))
  211.           print('Item [b] is now $' + str(a2))
  212.           break
  213.           #Break and exit loop
  214.  
  215.     if q2 == '$': #Inputted '$'
  216.       #Start Infinite loop
  217.       while True:
  218.         try:
  219.           #input prompt
  220.           b4_price2= float(input('What was the price of item [b] before the discount?: $')) #Input float for before price
  221.         except ValueError:
  222.           print('')
  223.           print('Please Enter a Number')
  224.         else:
  225.           break
  226.       while True:
  227.         try:
  228.           #input prompt
  229.           after_price2= float(input('What was the price of item [b] after the discount?: $')) #Input float for after price
  230.         except ValueError: #Error exception:
  231.           print('')
  232.           #Error prompt
  233.           print('Please Enter a Number')
  234.         else:
  235.           break
  236.           #Break and exit loop
  237.       #Rounding values
  238.       a2= round(a2, 2)
  239.       temp_a2= a2
  240.       p2= (after_price2/b4_price2)*100
  241.       d2= after_price2-b4_price2
  242.       d2= round(d2, 2)
  243.       print('The percentage discount on item [a] is %' + str(round(p1, 2)))
  244.  
  245.   print('')
  246.   print('[QUANTITY]') #Code Subheading
  247.   while True: #Start Infinite loop
  248.         try:
  249.           #Input prompt
  250.           b1= float(input("How many units does item [a] have?: ")) #Input float for unit quantity
  251.         except ValueError: #Error exception:
  252.           #Error prompt
  253.           print('Please Enter a Number')
  254.         else:
  255.           break
  256.           #Break and exit loop
  257.  
  258.   while True: #Start Infinite loop
  259.         try:
  260.           #Input prompt
  261.           b2= float(input("How many units does item [b] have?: ")) #Input float for unit quantity
  262.         except ValueError: #Error exception:
  263.           print('Please Enter a Number')
  264.           #Error prompt
  265.         else:
  266.           break
  267.           #Break and exit loop
  268.  
  269.   #Division to get value of both products        
  270.   a3= a1/b1
  271.   b3= a2/b2
  272.  
  273.   #Outputs:
  274.   if a3 > b3:
  275.     print('')
  276.     print('[BEST BUY]')
  277.     print('Item [b] is cheaper than item [a].')
  278.   if b3 > a3:
  279.     print('')
  280.     print('[BEST BUY]')
  281.     print('Item [a] is cheaper than item [b].')
  282.   if b3 == a3:
  283.     print('')
  284.     print('[BEST BUY]')
  285.     print('Item [a] and item [b] are the same price.')
  286.  
  287.   if Result_2 == 1:
  288.     if d1 > d2:
  289.       print('Item [a] saves you more money than item [b].')
  290.     if d1 < d2:
  291.       print('Item [b] saves you more money than item [a].')
  292.     if d1 == d2:
  293.       print('Item [a] and item [b] save you the same amount of money.')
  294.  
  295.   if Result_3 == 1:
  296.     if p1 > p2:
  297.       print('Item [a] saves you a bigger percentage than item [b].')
  298.     if p1 < p2:
  299.       print('Item [b] saves you a bigger percentage than item [a].')
  300.     if p1 == p2:
  301.       print('Item [a] and item [b] will save you the same percentage.')
  302.  
  303.   while True:
  304.     #Input prompt
  305.     print('')
  306.     terminate1= input("Do wish to terminate the program? (y/n): ")
  307.     #'y' or 'n' Input
  308.     if terminate1 == 'y' or terminate1 == 'n':
  309.       #Code is parsed
  310.       break
  311.       #Break and exit loop
  312.     else:
  313.       print('')
  314.       #Error prompt
  315.       print('Please type in "y" to answer "Yes" and type in "n" to answer "No"')
  316.  
  317.   if terminate1 == 'y': #Inputted 'y'
  318.     print('')
  319.     print('[PROGRAM TERMINATING]...')
  320.     sys.kill()
  321.   if terminate1 == 'n': #Inputted 'n'
  322.     print('[PROGRAM REPEATING]...')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement