|
C++ manual entry program
Hi. Not sure exactly where I should post this. The reason I am posting is to get discussion/feedback going on programming pace.
I'm a very rudimentary programmer. I do not know more about programming than is evident in the program I am about to present you with. It's manual entry.
I have problems with a mile seventy, and a mile forty. Whenever I put in 8.2 or 8.3, the program shuts down. 8.5 is OK. 6.5 is OK. It doesn't like 8.2, or 8.3. This is why I use 20 for 8.2, and 30 for 8.3.
Anyone have any methods to simplify?
Here it is: I use the Quincy 2005 compiler.: Distances: 4.5f to 9f:
Note that currently I print out F1 F2 F3, total energy and my interpretation of balance. Also energy for each fraction. :::::
//for complete program see the main Quincy 2005 directory
#include
using namespace std;
void fourPointFive();
void five();
void fivePointFive();
void six();
void sixPointFive();
void seven();
void eight();
void eightPointTwo();
void eightPointThree();
void eightPointFive();
void nine();
void menu();
void enterData();
void trackVariantFunction();
void calculate();
void printData();
float firstCall, secondCall, finalCall;
float firstFraction, secondFraction, thirdFraction;
float finalFraction, rawFinalFraction, beatenLengths;
float blFirst, blSecond, blFinal;
float EPR, LPR, TPR;
float trackVariant;
float balance;
//energy variables
float energy, firstFractionEnergy, secondFractionEnergy, thirdFractionEnergy;
int firstCallLength, secondCallLength, finalCallLength;
int horseNumber;
int routeMarker;
int main()
{
cout << "Note: For 1 mile 40 type in '20' and for 1 mile 70 type in '30' for some strange reason.\n";
cout << "enter 99 to quit";
routeMarker = 0;
menu();
}
void menu()
{
int choice;
float lengthOfRace;
cout << "\nEnter length of race in furlongs: (99 to quit) ";
cin >> lengthOfRace;
if(lengthOfRace == 4.5)
choice = 1;
if(lengthOfRace == 5)
choice = 2;
if(lengthOfRace == 5.5)
choice = 3;
if(lengthOfRace == 6)
choice = 4;
if(lengthOfRace == 6.5)
choice = 5;
if(lengthOfRace == 7)
choice = 6;
if(lengthOfRace == 8)
choice = 7;
if(lengthOfRace == 20)
choice = 8;
if(lengthOfRace == 30)
choice = 9;
if(lengthOfRace == 8.5)
choice = 10;
if(lengthOfRace == 9)
choice = 11;
switch(choice)
{
case 1:
fourPointFive();
break;
case 2:
five();
break;
case 3:
fivePointFive();
break;
case 4:
six();
break;
case 5:
sixPointFive();
break;
case 6:
seven();
break;
case 7:
eight();
break;
case 8:
eightPointTwo();
break;
case 9:
eightPointThree();
break;
case 10:
eightPointFive();
break;
case 11:
nine();
break;
case 99:
break;
}
}
void enterData()
{
cout << "First Call: "; cin >> firstCall;
cout << "Second Call: "; cin >> secondCall;
cout << "Final Call: "; cin >> finalCall;
cout << "Beaten lengths first: "; cin >> blFirst;
cout << "Beaten lengths second: "; cin >> blSecond;
cout << "Beaten lengths final: "; cin >> blFinal;
cout << "Track Variant: "; cin >> trackVariant;
trackVariantFunction();
}
void trackVariantFunction()
{
if (trackVariant < 6)
{
trackVariant = 6;
}
if (trackVariant > 28)
{
trackVariant = 28;
}
if (trackVariant > 18)
{
trackVariant = (trackVariant - 18) / 5;
finalCall = finalCall - (trackVariant * .33);
secondCall = secondCall - ((trackVariant / 2)*.33);
goto byPass;
}
if (trackVariant < 16)
{
trackVariant = (16 - trackVariant) / 5;
finalCall = finalCall + (trackVariant * .33);
secondCall = secondCall + ((trackVariant / 2) * .33);
}
byPass:
calculate();
}
void calculate()
{
firstFraction = (firstCallLength - (blFirst * 10)) / firstCall;
secondFraction = (secondCallLength - ((blSecond - blFirst) * 10)) / (secondCall - firstCall);
thirdFraction = (finalCallLength - ((blFinal - blSecond) * 10)) / (finalCall - secondCall);
//energy calcs
energy = firstFraction + secondFraction + thirdFraction;
firstFractionEnergy = firstFraction / energy;
secondFractionEnergy = secondFraction / energy;
thirdFractionEnergy = thirdFraction / energy;
//balance = (firstFractionEnergy - thirdFractionEnergy) * 1000;
balance = ((firstFractionEnergy + secondFractionEnergy) -
(secondFractionEnergy + thirdFractionEnergy)) * 1000;
cout << endl << endl;
EPR = ((firstCallLength + secondCallLength) - (blSecond * 10)) / secondCall;
LPR = (secondFraction + thirdFraction) / 2;
TPR = (EPR + LPR);
printData();
}
void printData()
{
//energy
cout << "\nfirstFractionEnergy: " << firstFractionEnergy;
cout << "\nsecondFractionEnergy: " << secondFractionEnergy;
cout << "\nthirdFractionEnergy: " << thirdFractionEnergy;
cout << "\ntotalEnergy: " << energy;
cout << "\nbalance: " << balance;
cout << endl;
cout << "\nfirstFraction: " << firstFraction;
cout << "\nsecondFraction: " << secondFraction;
cout << "\nthirdFraction: " << thirdFraction;
/*
cout << "\nEPR: " << EPR;
cout << "\nLPR: " << LPR;
cout << "\nTPR: " << TPR / 2;
cout << endl;
*/
menu();
}
void fourPointFive()
{
cout << "Four and a Half\n";
firstCallLength = 1320;
secondCallLength = 1320;
finalCallLength = 330;
enterData();
}
void five()
{
cout << "five\n";
firstCallLength = 1320;
secondCallLength = 1320;
finalCallLength = 660;
enterData();
}
void fivePointFive()
{
cout << "five and a Half\n";
firstCallLength = 1320;
secondCallLength = 1320;
finalCallLength = 990;
enterData();
}
void six()
{
cout << "six\n";
firstCallLength = 1320;
secondCallLength = 1320;
finalCallLength = 1320;
enterData();
}
void sixPointFive()
{
cout << "six and a Half\n";
firstCallLength = 1320;
secondCallLength = 1320;
finalCallLength = 1650;
enterData();
}
void seven()
{
cout << "seven\n";
firstCallLength = 1320;
secondCallLength = 1320;
finalCallLength = 1980;
enterData();
}
void eight()
{
cout << "eight\n";
routeMarker = 5;
firstCallLength = 2640;
secondCallLength = 1320;
finalCallLength = 1320;
enterData();
}
void eightPointTwo()
{
cout << "a mile 40\n";
routeMarker = 5;
firstCallLength = 2640;
secondCallLength = 1320;
finalCallLength = 1440;
enterData();
}
void eightPointThree()
{
cout << "a mile seventy\n";
routeMarker = 5;
firstCallLength = 2640;
secondCallLength = 1320;
finalCallLength = 1530;
enterData();
}
void eightPointFive()
{
cout << "a mile and a sixteenth\n";
routeMarker = 5;
firstCallLength = 2640;
secondCallLength = 1320;
finalCallLength = 1650;
enterData();
}
void nine()
{
cout << "nine\n";
routeMarker = 5;
firstCallLength = 2640;
secondCallLength = 1320;
finalCallLength = 1980;
enterData();
}
|