Skip to content

Instantly share code, notes, and snippets.

@mattsegura
Created December 6, 2020 04:39
Show Gist options
  • Save mattsegura/d76add25b59e93f57354545e8aa1b607 to your computer and use it in GitHub Desktop.
Save mattsegura/d76add25b59e93f57354545e8aa1b607 to your computer and use it in GitHub Desktop.
Intilization and test will have max and min, Initilization with min and test with max
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// constants
const int START_KPH = 60,
END_KPH = 130,
INCREMENT = 10;
// CONSTANT FOR SPEED CONVERSION
const double CONVERSION_FACTOR = 0.6214;
int kphap
;
double mph;
// set the numeric output format
cout << fixed << showpoint << setprecision(1);
// display
cout << "KPH\tMPH\t";
cout << "---------\n";
// display speeds.
for (kph = START_KPH; kph <= END_KPH; kph += INCREMENT)
{
// calculate mph
mph = kph * CONVERSION_FACTOR;
// display the speeds in kph and mph
cout << kph << "\t" << mph << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment