[Tutor] if/else option for making a choice
n.rautenhaus at gmx.de
Mon Feb 18 19:22:54 CET 2013
I would be very pleased if someone is able to help me.
I wrote a small programm, to calculate the grand total for a car.
A basic price can be entered. Given that basic price, a tax peercentage is
calculated and added tot he grand total.
But unfortunately I am stuck with giving the user the choice to select an
The extra items have got set values, but at the moment they all get
summarized, but i want to choose.
AFAIK I already tried:
Print raw_input ((Would you like to have leather?) à then yes or no
If raw_input == yes
Print Leather (Leather) ß displaying the variables value
Plus adding the item at the end to concatenate it with the basic value.
I hope it is clear where my problem is.
My code I already wrote:
#Car price calculator
# Set variables for additional items
Leather = (500)
Clima = (1500)
Hifi = (250)
Electrics = (750)
Comfort = (2500)
print "\t\t\tWelcome to the car price calculator!"
print "\t\t\tCredits belong to Niclas Rautenhaus"
print "\n\nPlease enter the basic price: "
basic = int (raw_input())
# Tax is a percentage of the basic car price
Tax = basic * 5 / 100
print "\nAdded items:"
# Here the user should have the possibility to pick either yes or no
print "Hifi", (Hifi)
print "Electrics", (Electrics)
print "Comfort", (Comfort)
print "Tax", (Tax)
# Last step: the picked items shall be summarized
print "\n\nTotal grand:", basic + Leather + Clima + Hifi \
+ Electrics + Comfort + Tax
raw_input ("\nPress the enter key to exit!")
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor