gallons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • imran akhtar
    New Member
    • Nov 2008
    • 64

    gallons

    i have to Write a program that asks the user to input
    • The capacity in gallons of a fuel tank
    • The fuel efficiency in miles per gallon
    • The price of a gallon of petrol

    below is the code that i have written, can anyone double cheak, and to see wht can be changed and how it can be improved.i have also attched txt file, in order to see it clearer

    Code:
    print "----welcome----"
    
    
    capacity = input ("please enter the capacity of the fuel tank in gallons, gallons must be between 6 & 20:")
    while capacity < 6 or capacity > 20:
     capacity = input ("sorry invalid number,please enter gallons  between 6 & 20:")
    
    
    
    
    efficiency = input ("please enter the fuel efficiency in MPG, efficiency must be between 20 & 75:")
    while efficiency < 20 or efficiency > 75:
        efficiency = input("sorry invalid number,please enter MPG  between 20 & 7:")
    
    pricepergallon=input ("price per gallon of petrol? £, price must be between £3.20&4.20:")
    
    while pricepergallon < 3.20 or pricepergallon > 4.20:
     pricepergallon= input ("sorry invallid price,please enter price between £3.20 & £4.20:")
    
    carcango= capacity * efficiency
    
    print " on a full tank, the car can travel" ,carcango, "miles"
    
    print "the cost of travelling 100 miles is £", (100.0/efficiency *pricepergallon)
    
    print "end of program"
    Attached Files
  • imran akhtar
    New Member
    • Nov 2008
    • 64

    #2
    please is there anyone who can help with this question

    Comment

    • boxfish
      Recognized Expert Contributor
      • Mar 2008
      • 469

      #3
      As far as I can tell, your program is fine; what do you want help with?

      Comment

      • imran akhtar
        New Member
        • Nov 2008
        • 64

        #4
        to make it look more effecint, and if you can give suggestion on how to re-word it.

        Comment

        Working...