******
// the program can now output the result
cout << endl << endl << endl; // skip some spaces
cout << "Your Blood Alcohol Content after drinking " << drinks <<" "
<< alcoholType << " at " << percent << "% " << "over a "
<< time << " hour span is: " << endl << endl << " : "
<< BAC << " BAC." <<endl <<endl;
cout << "The maximum BAC before aggrevated DUI in " << searchState << "is " << maxBAC << endl;
cout << "The minimum penalty in " << searchState << "is " << minPenalty << endl;
if (BAC > LEGAL_LIMIT)
cout << "You are legally impaired and should not drive" << endl;
else
cout << "You are not legally impared" << endl;
return 0;
}
LA .20 45
ME .15 90
MD .15 90
MA .20 90
I am having a problem with my code... I figured I would post the whole code just to make it easier for everyone to understand what I was doing (put a line of asterisks above and below the code I believe is causing the issues) . Fairly simply BAC calculator, and I am trying to get data from a text tile, which you can see a sample of just below the code. I am attempting to store the information in an array which can be displayed with the final calculation. It compiles fine, but when I get to the part where I enter the state, I get nothing back. I would appreciate any suggestions/help anyone can provide.
Please use code tags and properly format your code before posting. If you don't know how to use code tags then reed this article. http://www.cplusplus.com/articles/z13hAqkS/
Your not inputting the data from your file properly. The variable state is declared as a double, but you are trying to input a string into it. Try declaring your state variable as a string. I don't think this will solve all your problems but it should get you started.
As you will see here I changed the variable from maxBAC and maxPenalty to state, but the values I got were not correct.
Your Blood Alcohol Content after drinking 3 beers at 4% over a 5 hour span is:
: -0.0205765
The maximum BAC before aggrevated DUI in MA is -858993460
The minimum penalty in MA is -8589993460
You are not legally impared
Press any key to continue...
Do you have any other suggestions for as how to proceed?
The output is as shown below, where nothing returns rather than -858993460
Your Blood Alcohol Content after drinking 3 beers at 4% over a 5 hour span is:
: -0.0205765
The maximum BAC before aggrevated DUI in MA is
The minimum penalty in MA is
You are not legally impared
Press any key to continue...