Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main()
  5.  
  6. // a program to convert gallons to liters
  7.  
  8. { const int MAXGALLONS=20;
  9. const int STARTVAL=10 ;
  10. const int STEPSIZE=1;
  11. int gallons;
  12. double liters;
  13.  
  14. cout << "GALLONS LITERS\n";
  15. cout << "------- -------\n" << endl;
  16.  
  17. gallons=STARTVAL;
  18.  
  19. // set output formats for floating-point numbers only
  20.  
  21. cout << setiosflags (ios::showpoint) << setiosflags (ios::fixed)
  22. << setprecision(3);
  23.  
  24. while (liters>=gallons)
  25.  
  26. { cout << setw(4) << gallons;
  27. cout << setw(9) << liters;
  28. gallons = 3.785*liters;
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement