Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- void printwarning();
- void printokay();
- void main()
- {
- double milesremaining, fuelremaining, mpg, fuelmiles;
- cout<<"How many miles are you from the next gas station? ";
- cin>>milesremaining;
- cout<<"How much fuel do you have left (in gallons)? ";
- cin>>fuelremaining;
- cout<<"What is your average miles to the gallon? ";
- cin>>mpg;
- fuelmiles=fuelremaining*mpg;
- if(fuelmiles<milesremaining)
- printwarning();
- else
- printokay();
- }
- void printwarning()
- {
- cout<<"Warning: Calculations indicate that you will run out of fuel ";
- cout<<"before the next avaliable gas station."<<endl;
- }
- void printokay()
- {
- cout<<"You will make it to the next gas station."<<endl;
- }
Add Comment
Please, Sign In to add comment