Solution

// Programmer: Clayton Price

// File: h2.cpp class: cs1570

// Purpose: this file contains the main function for the program that will

// the number of tablets (dosage) prescribed by Dr. Nick Riviera based on

// some nonsense information.

#include <iostream>

using namespace std;

int main()

{

/* ------------------------ DECLARATIONS ------------------ */

const short TABLET_STRENGTH = 250; // in mg

const short DR_NICKS_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. Nick Riviera'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. Nick wanted.

dosage = static_cast<short>(((static_cast<float>(age)/iq) * (wt/freq + 1)

* ((TABLET_STRENGTH/1000) + 1) + DR_NICKS_MIN_SALE) );

cout<<"\n\n\t\t......computing.................."<<endl<<endl;

cout<<"\tDr. Nicks 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;

}