Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <cstdlib>
- #include <math.h>
- float zao(float a) {
- return round(a*100)/100;
- }
- int main()
- {
- system("color F8");
- float vol;
- float per;
- float wgh;
- float hgh;
- float hours = 0;
- double var0m = 2.447;
- double var1m = 0.09156;
- double var2m = 0.1074;
- double var3m = 0.3362;
- double var0fm = -2.097;
- double var1fm = 0.1069;
- double var2fm = 0.2466;
- double token;
- float safebac;
- float safebacm;
- float sd;
- float bac;
- float mr = 0.017;
- float water = 0.806;
- float alh;
- float alm;
- float reaction;
- int age;
- int sex;
- std::cout << "Input your weight (in kg): ";
- std::cin >> wgh;
- if (wgh > 150)
- {
- std::cout << "NOTE: Weight input exceeded 150kg, proceeding...\n";
- }
- std::cout << "Input your height (in cm): ";
- std::cin >> hgh;
- if (hgh > 250)
- {
- std::cout << "NOTE: Height input exceeded 250cm, prooceding...\n";
- }
- std::cout << "Provide your age: ";
- std::cin >> age;
- if (age > 120)
- {
- std::cout << "NOTE: Age input exceeded 120, proceeding...\n";
- }
- if (((wgh)/(hgh*hgh))*1000>= 50)
- {
- std::cout << "WARNING: Unable to handle BMI (unnatural input: " << zao((((wgh)/(hgh*hgh))*10000)) << ")\n";
- }
- std::cout << "Provide your gender (1 for female, 0 for male): ";
- std::cin >> sex;
- std::cout << "Input volume of alcohol drink you have consumed (in ml): ";
- std::cin >> vol;
- std::cout << "Input alcohol volume in alcohol drink you have consumed (in %): ";
- std::cin >> per;
- std::cout << "Provide drinking period in hours: ";
- std::cin >> hours;
- if (hours == 0)
- {
- std::cout << "WARNING: 0 drinking hours. Token set: 1";
- hours = 1;
- }
- system("CLS");
- std::cout << "We have provided specified informations: \n";
- std::cout << "Your weight is: " << wgh << "kg\n";
- std::cout << "Your height is: " << hgh/100 << "m\n";
- if (sex == 1)
- {
- token=(var0fm + (var1fm * hgh) + (var2fm * wgh))/wgh;
- std::cout << "You're " << age << " female (token set: " << token << ")\n";
- } else if (sex == 0) {
- token=(var0m - (var1m * age) + (var2m * hgh) + (var3m * wgh))/wgh;
- std::cout << "You're " << age << " male (token set: " << token << ")\n";
- } else if (sex != 1 && sex != 0) {
- std::cout << "Cannot recognize gender (token set: 6,615)\n";
- token=6.615;
- }
- sd = ((vol*(per/100))/10);
- bac = (((water*sd*1.2)/(token*wgh))-mr*hours)*10;
- safebac = round(zao(bac-0.2)/0.15);
- safebacm = zao(bac-0.2)/0.15 - safebac;
- alh = round(zao(bac/0.15));
- alm = zao(bac/0.15) - alh;
- reaction = ((bac*130)/0.2)-bac;
- if (bac <= 0)
- {
- bac = 0.00;
- }
- std::cout << "\n" << "You've consumed " << vol << "ml of alcoholic drink. (alc. vol. " << per << "%)\n";
- std::cout << "Alcohol you've consumed in grams: " << vol*(per/100) << "g. (" << sd << " standard portions)\n";
- std::cout << "Estimated values:\n";
- std::cout << "- peak alcohol concentration: " << zao(bac) << "%\n";
- if (bac > 0)
- {
- std::cout << "- alcohol metabolism in hours: " << alh << "h " << round(alm*60)*-1 << "m\n";
- }
- else
- {
- std::cout << "- alcohol metabolism in hours: sober (since: " << alh*-1 << "h " << round(alm*60) << "m)\n";
- }
- if (bac <=0.2 )
- {
- std::cout << "- visible direct alcohol effect in hours: none\n";
- }
- else
- {
- if (safebacm < 0)
- {
- safebacm = 0;
- }
- std::cout << "- visible direct alcohol effect in hours: " << safebac << "h " << round(safebacm*60) << "m\n";
- }
- if (reaction > 0)
- {
- if (reaction >= 1000)
- {
- std::cout << "- possible reaction time delay: " << round(reaction/1000) << "s (increased by: " << zao(bac*13)/0.2 << "%)\n";
- }
- else if (reaction <= 1000)
- {
- std::cout << "- possible reaction time delay: " << round(reaction) << "ms (increased by: " << zao(bac*13)/0.2 << "%)\n";
- }
- }
- else
- {
- std::cout << "- possible reaction time delay: none\n";
- }
- if (bac >= 0.4)
- {
- std::cout << "- possibility of alcohol poisoning: " << zao(bac*100/3.5) << "%\n";
- }
- else
- {
- std::cout << "- possibility of alcohol poisoning: 0%\n";
- }
- std::cout << "\n\nNOTE: You SHOULD not fully trust provided informations ought these may be lowered or the opposite.\n";
- std::cout << "This application is recommended for self draft-test purposes only. For the most proximate outcome\n";
- std::cout << "please use breath analyzer.\n";
- std::cout << "Driving ANY kind of vehicle after alcohol intake is highly not recommended when unsure of\n";
- std::cout << "the actual BAC.";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement