
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>

using namespace std;

double pressure(double b, double i, double t){
	double p;
	double c = (b/2)+t;
	double eT = 207000000000;
	double vT = 0.28;
	double eH = 207000000000;
	double vH = 0.28;
	p = (i/(b/2))/((1/eT)*(((pow(c,2)+pow((b/2),2))/(pow(c,2)-pow((b/2),2)))+vT)+(1/eH)*(1-vH));
	return p;
}// end function

int main(void) {

double b, i, t, p, tcm, mPa;
double thick;
double z = 100;
cout << "Enter hub diameter and interference" << endl;
cin >> b >> i;

while (b != 0 || i != 0){
	if (b>=0.5 && b<=2.5 && i >0 && i<(0.005*b)){
		cout << " Thickness (cm)  Pressure (MPa)" << endl;
		cout << "--------------------------------------" << endl;
		
		t = 0.06;
		tcm = 6.0;
		cout << "     " << setprecision(1) << tcm << "          ";
		while(t<=0.12){
			p = pressure(b, i, t);
			mPa = p/1000000;
			cout << fixed  << setprecision(4)<< mPa << endl;
			if(z>abs(mPa-20)){
				thick = tcm;
				z = abs(mPa-20);
			}
			
			t = t+0.005;
			tcm = tcm + 0.5;
			if(tcm>=10){
				cout << "    " << setprecision(1) << tcm << "          ";
			}else{
			cout << "     " << setprecision(1) << tcm << "          ";
		}//end if
		}//end while
		
			p = pressure(b, i, t);
			mPa = p/1000000;
			cout << fixed  << setprecision(4)<< mPa << endl;
			cout << "A tire thickness of " << setprecision(1) << thick << " cm comes closest to giving a pressure of 20MPa." << endl;
			
	}else{
		cout << "Invalid values ignored." << endl;
	}//end if
	
	cout << "Enter hub diameter and interference" << endl;
    cin >> b >> i;
}//end while



	system("PAUSE"); return 0;
}
