Python Forum
python in JES homework question, - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: python in JES homework question, (/thread-8163.html)



python in JES homework question, - lsteffen - Feb-07-2018

I am using JES to learn python. My teacher gave us a project but my code is not working. I believe the problem lies on line 35 but I don't know what I am doing wrong. I need someone to please explain it to me.

Thank you
Lisa S

[def main():
# show dialog box with "Welcome to Acme Corporation, your one-stop Widget superstore!"
  showInformation( "Welcome to Acme Corporation, your one-stop WIdget superstore!" )
# show dialog box with "Cost $10.00 per unit with volume discounts as follows:"
  showInformation( "Cost $10.00 per unit with volume discounts as follows:" )
# show dialog box with 4 lines of text showing "11-30 = 10% off, 31-70 = 15% off, 71-100 = 20% off, 101+ = 25% off
  showInformation( "11-30 = 10% off \n31-70 = 15% off \n71-100 = 20% off \n101+ = 25% off" )
# ask user for number of widgets they wish to by as an integer from 1 to 1000 inclusive using the words minimum quantity is 1 and the maximum is 1000
  number_of_widgets = requestInteger( "How many widgets would you like to buy? \nThe minimum quantity you can order is 1 and the maximum is 1000" )
# create if statement if number of widgets is < 1 or > 1000 a dialog box will say "The minimum order is 1 and the maximum is 1000. Goodbye." and ends the program
  if number_of_widgets < 1 or number_of_widgets > 1000:
    showInformation( "The minimum order is 1 and the maximum is 1000. \n Goodbye." )
# create and else statement if number of widgets is in the correct range
# create a nested if statement to compute the discount amount based on the number order using  variable for unit cost of $10.00 and a base cost for the order before discount is applied
  else:
    base_cost = float(number_of_widgets*10.00)
  printNow( number_of_widgets )
  printNow( base_cost )
# create a nested if statement based on the number ordered to store the varialbe discount to store the whole number of the corresponding discount
  if number_of_widgets >= 11 and number_of_widgets <= 30:
    discount = 10
  elif number_of_widgets >= 31 and number_of_widgets <= 70:
    discount = 15
  elif number_of_widgets >= 71 and number_of_widgets <= 100:
    discount = 20
  elif number_of_widgets >= 101 and number_of_widgets <= 1000:
    discount = 25
  printNow( discount )
# convert  discount to decimal number variable named discount_percentage
  discount_percentage = float(discount/100)
  printNow( discount_percentage )
# calculate the final cost as base cost - discount_percentage * base cost
  final_cost = float(base_cost-(discount_percentage*base_cost))
  printNow( final_cost )
# show dialog box displaying the number of widgets ordered, the discount percentage applied, and the final cost
  showInformation( "You have ordered " + str(number_of_widgets) + " number of Widgets. \nThis means you are eligable for " + str(discount) + "% off. \nSo your final cost is $" + str(final_cost))
# Ask user if they wish to submit the order using a string "Y for yes N for no"
  correct = requestString( "Would you like to submit the order? \n Plese give a Y for Yes and an N for no" )
# create if statement if string is equal to "Y" or "y" then display a dialog box saying "Thanks for your order else say "Maybe next time..."
  if correct == "Y" or correct == "y":
    showInformation( "Thanks for your order!" )
  else:
    showInformation( "Maybe next time..." )



RE: python in JES homework question, - Taco_Town - Feb-11-2018

Did you get the answer to this figured out?