Skip to content
Advertisement

How to ask if a user is a member and if so, display their discounted price and how to add all values up? [closed]

I want to ask the user if they are members and if so, give them a 5% discount on the seats they have purchased, if they are not members, there is no discount. I also want to display that discounted price. Also, how would I go about adding up all the final prices and displaying those as well? I don’t know where to start with this, any help is appreciated, thanks. There may be some formatting issues, but here is my code:

JavaScript

Advertisement

Answer

This is how I would resolve all of your questions:

JavaScript

Please note these

  1. I change the location of the calls to your functions and set a variable to receive them
  2. I changed the prints for the final price to an f string to receive the variables from the functions
  3. Changed Finalorchp to the pythonic version of variable = variable * .95 right under the if member statement
  4. Changed the else statement in get_orchp to else in the event that the user doesn’t only put y or n (you could add onto this to have fault tolerance of if it isn’t y or n then do something else)
  5. Added another final price print with an f string to add the two variables that receive the 2 variables from the functions.
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement