fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int mile=0;
  6. int gallon=0;
  7. int TM=0; //total mile
  8. int TG=0; //total gallon
  9. double MPG=0;
  10. double Total=0;
  11. while(mile!=0)
  12. {
  13. cin>>mile>>gallon;
  14. MPG=mile/gallon;
  15. TM=TM+mile;
  16. TG=TG+gallon;
  17. Total=TM/TG;
  18. cout<<"MPG this trip:"<<MPG<<endl<<"Total MPG:"<<Total<<endl;
  19. cout<<"Enter miles driven (-1 to quit):"<<mile<<endl<<"Enter gallons used:"<<gallon<<endl;
  20. }
  21. return 0;
  22. }
  23.  
  24.  
Success #stdin #stdout 0.01s 5312KB
stdin
200 25
stdout
Standard output is empty