Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- double miles,gallon,MPG,total=0,avg=0,avg1=0,count=0;
- while(miles>=-1)
- {
- cout<<"Enter miles driven(-1 to quit):"<<endl;
- cin>>miles;
- if(miles==-1)
- break;
- else
- cout<<"Enter gallons used:"<<endl;
- cin>>gallon;
- MPG=miles/gallon;
- avg+=miles;
- avg1+=gallon;
- cout<<"MPG this tankfull:"<<MPG<<endl;
- total=avg/avg1;
- cout<<"total MPG:"<<total<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement