#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>



void Usage(void){
	printf("\t./trailer [bed length] [hitch length] [hitch weight percent]\n");
}

int main(int argc, char **argv){

/*
	double W[3] = {1000, 1000, 200};
	double L[3] = {};
	uint32_t num1;
	W1*L1 = W2*L2
La / Lh = Wh / Wa
La = Wh / Wa * Lh
*/

	if(argc != 4){
		Usage();
		exit(1);
	}

	const double wheelbase = 103;
	const double Wb = 2000;
	double Lb = atof(argv[1]);
	double Lt = atof(argv[2]);
	double Per = atof(argv[3]);
	double Lh = Lb/2  + Lt;
	double Wh = Wb*Per/100;
	double Wa = Wb-Wh;

	double La = Wh/Wa * Lh;

	//printf("axle from front: %lf back: %lf\n", Lb/2+La, Lb/2-La);


	printf("tower wheelbase: %.03lf\n", wheelbase);
	printf("trailer weight: %.03lf\n", Wb);
	printf("bed length: %.03lf\n", Lb);
	printf("hitch length: %.03lf\n", Lt);
	printf("total length: %.03lf\n", Lb+Lt);
	printf("hitch weight: %.03lf(%%%.03lf)\n", Wh, Per);
	printf("axle weight: %.03lf(%%%.03lf))\n", Wa, Wa/Wb*100);
	printf("axle from front: %.03lf\n", Lb/2+La);
	printf("axle from back: %.03lf\n", Lb/2-La);
	printf("center of gravity from ball: %.03lf\n", Lt+Lb/2);
	printf("center of gravity from back: %.03lf\n", Lb/2);
	printf("total trailer length: %.03lf\n", Lb+Lt);

	return 0;
}
