Solution

// Programmer: Clayton Price date: Sept. 15, 2014 // File: h2.cpp class: cs1570 // Purpose: this file contains the main function for the program that will compute // the number of tablets (dosage) prescribed by Dr. Eloe based on // some nonsense information. #include <iostream> using namespace std; int main() { /* ------------------------ DECLARATIONS ------------------ */ const short TABLET_STRENGTH = 250; // in mg const short DR_ELOES_MIN_SALE = 20; // min no of tabs to sell short dosage = 0; // calculated val for prescptn // input values// string name; // users name short age = 0; // users age short iq = 0; // intel quotient short freq; // num tabs per day desired short gender; // 0-female, 1-male float wt; // users weight (kg) /* ----------------------- GREETINGS AND INPUT ------------ */ cout<<"\t\tHELLLOO EVV-RYBODY!"<<endl <<"\tDr. Eloe's Medical offices"<<endl<<endl; cout<<"Please answer the following questions for your auto-prescription!"<<endl; cout<<"\n\tWhat is your name: "; cin>>name; cout<<"\nOk, "<<name<<", what is "<<endl <<"\tyour age: "; cin>>age; cout<<"\tyour wt(kg): "; cin>>wt; cout<<"\tyour IQ: "; cin>>iq; cout<<"\tgender(1-male,0-female): "; cin>>gender; cout<<"\tprefered num tabs/day: "; cin>>freq; /* ---------------------- COMPUTATIONS AND OUTPUT ------------ */ // the following formula is nonsense, but it's what Dr. Eloe wanted. dosage = static_cast<short>(((static_cast<float>(age)/iq) * (wt/freq + 1) * ((TABLET_STRENGTH/1000.0) + gender) + DR_ELOES_MIN_SALE) + 0.5); cout<<"\n\n\t\t......computing.................."<<endl<<endl; cout<<"\tDr. Eloe's recommendation for "<<name<<" is: "<<dosage<<" tablets" <<" based on: "<<endl <<"\tage: "<<age<<" years"<<endl <<"\tweight: "<<wt<<" kgs"<<endl <<"\tIQ: "<<iq<<" (a bit inflated)"<<endl <<"\tgender: "<<(gender?"male":"female")<<endl // the ternary operator was used for gender output for ease // <<"\tdesired num tabs/day: "<<freq<<endl<<endl; cout<<"Wishing you a great day!"<<endl<<endl; return 0; }