I'm writing a program where I need to generate a conversion table for wrench sizes with the following columns: Size (Inches) [Fraction], Size (Inches) [Decimal rounded to 3], Next Bigger Metric (mm), Difference (Inches) [Next Bigger Metric-Inches], Closest Metric (mm) [to original size], and Difference (Inches) [Closest Metric-Inches]. I've created the column for the Size in fraction form relatively quickly but I cant seem to produce the decimal version. Instead, I get 0.000. Can somebody please take a look and see what I've missed? Thank you!
Code:
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
float wrenchSize , difference1 , difference2 , SI;
int i, nextmetric, closestMetric;
cout.setf(ios::fixed);
cout.precision(3);
cout << " Size Size Next Bigger Difference Closest Difference" << endl;
cout << "(Inches) (Inches) Metric (mm) (Inches) Metric (mm) (Inches)" << endl;
for(int i = 5; i <= 32; i++)
{
SI = i/32 ;
nextmetric = ceil(SI) ;
cout << setw(3) << i << "/32 " << setw(9) << SI << setw(8) << nextmetric << endl;
//cout << setw(13) << difference1 << setw (14) << closestMetric << setw (13) << difference2 << endl;
}
system("PAUSE");
return 0;
}