Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. double miles,gallon,MPG,total=0,avg=0,avg1=0,count=0;
  6.  
  7.  
  8. while(miles>=-1)
  9. {
  10. cout<<"Enter miles driven(-1 to quit):"<<endl;
  11. cin>>miles;
  12. if(miles==-1)
  13. break;
  14. else
  15. cout<<"Enter gallons used:"<<endl;
  16. cin>>gallon;
  17.  
  18.  
  19. MPG=miles/gallon;
  20. avg+=miles;
  21. avg1+=gallon;
  22.  
  23. cout<<"MPG this tankfull:"<<MPG<<endl;
  24. total=avg/avg1;
  25.  
  26. cout<<"total MPG:"<<total<<endl;
  27. }
  28.  
  29.  
  30. return 0;
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement