473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

Expand|Select|Wrap|Line Numbers
  1. print "----welcome----"
  2.  
  3.  
  4. capacity = input ("please enter the capacity of the fuel tank in gallons, gallons must be between 6 & 20:")
  5. while capacity < 6 or capacity > 20:
  6.  capacity = input ("sorry invalid number,please enter gallons  between 6 & 20:")
  7.  
  8.  
  9.  
  10.  
  11. efficiency = input ("please enter the fuel efficiency in MPG, efficiency must be between 20 & 75:")
  12. while efficiency < 20 or efficiency > 75:
  13.     efficiency = input("sorry invalid number,please enter MPG  between 20 & 7:")
  14.  
  15. pricepergallon=input ("price per gallon of petrol? £, price must be between £3.20&4.20:")
  16.  
  17. while pricepergallon < 3.20 or pricepergallon > 4.20:
  18.  pricepergallon= input ("sorry invallid price,please enter price between £3.20 & £4.20:")
  19.  
  20. carcango= capacity * efficiency
  21.  
  22. print " on a full tank, the car can travel" ,carcango, "miles"
  23.  
  24. print "the cost of travelling 100 miles is £", (100.0/efficiency *pricepergallon)
  25.  
  26. print "end of program" 
Attached Files
File Type: txt gallons1.txt (949 Bytes, 420 views)
Dec 17 '08 #1
3 1815
please is there anyone who can help with this question
Dec 18 '08 #2
boxfish
469 Expert 256MB
As far as I can tell, your program is fine; what do you want help with?
Dec 18 '08 #3
to make it look more effecint, and if you can give suggestion on how to re-word it.
Dec 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

34
by: E. Robert Tisdale | last post by:
Please find attached the physical constants header file physical.h It defines conversion factors to mks units. It might be used like this: > cat main.cc #include<iostream>...
15
by: Dave | last post by:
Hello NG, It is well known that memory-allocating definitions should not be put in a header file. I believe, however, that this does not apply to const definitions. For example: #ifndef...
7
by: Eric Whittaker | last post by:
Hey guys, i am relatively new at this programming thing and am stuck on an assignment here. I'm trying to get the program below to respond to the integer -1 to stop and calculate total. It does,...
6
by: jimfortune | last post by:
In: http://groups.google.com/group/comp.databases.ms-access/msg/60d7faa790c65db1 james.ea...@gmail.com said: :Ok, I've answered the first half of my own question. From a MSDN :article, I...
6
by: Niu Xiao | last post by:
In the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with the following puzzle. They were given a 3-gallon jug and a 5-gallon jug and were asked to fill the 5-gallon jug...
27
by: galt_57 | last post by:
I need to do just a few multiplies of long integers and have a divide by ten. Can I avoid using floats? Can I use two longs as a 64 bit value somehow? Thanks.
2
by: erekose666 | last post by:
I need some help here if anyone is willing. I need to take this program and modify it to do something a little different. First things first, though. If you run this code like it is right now, it...
21
by: javasomething | last post by:
I need to finish this assignment can someone help me plz. The Car Class The purpose of this assignment is to learn how to write your own class that serves as a template for creating objects....
5
by: imran akhtar | last post by:
here i have made code, how could i imporve this version of my code, and make it more effeicnt. below is the code. i have Write a program that asks the user to input • The capacity in gallons of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.