1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
#include <iostream>
#include <string>
using namespace std;
// Functions Used.
void ironPill(string, bool&); // Function Prototype.
void antibioticPill(string, bool&); // Function Prototype.
void aspirinPill(string, bool&); // Function Prototype.
void decongestantPill(string, bool&); // Function Prototype.
void printReport(bool, bool, bool, bool); // Function Prototype.
bool goPrintironPill;
bool goPrintantibioticPill;
bool goPrintaspirinPill;
bool goPrintdecongestantPill;
int proceed;
int hourCount;
int clock;
string medTime;
int main (){
cout << "Good morning, are ready for your pill schedule. Enter 1 to continue: " << endl;
cin >> proceed;
if (proceed != 1)
{
cout << "Enjoy your morning and try again when ready." << endl;
}
else
{
cout << "Please enter the next nearest hour (e.g., 0800, 1300, 2100, etc): " << endl;
cin >> medTime;
ironPill (medTime, goPrintironPill);
antibioticPill(medTime, goPrintantibioticPill);
aspirinPill(medTime, goPrintaspirinPill);
decongestantPill(medTime, goPrintdecongestantPill);
printReport(goPrintironPill, goPrintantibioticPill, goPrintaspirinPill, goPrintdecongestantPill);
cout << "Iron Pill is " << goPrintironPill << endl; // Test: to ensure the bool value is correct.
cout << "Antibiotic Pill is " << goPrintantibioticPill << endl; // Test: to ensure the bool value is correct.
cout << "Aspirin Pill is " << goPrintaspirinPill << endl; // Test: to ensure the bool value is correct.
cout << "Decongestant Pill is " << goPrintdecongestantPill << endl; // Test: to ensure the bool value is correct.
}
return 0;
}//End main
void ironPill(string medTime, bool& goPrint) // Function determines if the enter time is a time required for a pill.
{
if (medTime == "0800" || medTime == "1200" || medTime == "1800")
{
goPrintironPill = true;
} // End if.
else
{
goPrintironPill = false;
} // End else.
} // End ironPill.
void antibioticPill(string medTime, bool& goPrint) // Function determines if the enter time is a time required for a pill.
{
if (medTime == "0400" || medTime == "0800" || medTime == "1200" || medTime == "1600" || medTime == "2000" || medTime == "2400" || medTime == "0000")
{
goPrintantibioticPill = true;
} // End if.
else
{
goPrintantibioticPill = false;
} // End else.
} // End antibioticPill.
void aspirinPill(string medTime, bool& goPrint) // Function determines if the enter time is a time required for a pill.
{
if (medTime == "0800" || medTime == "2100")
{
goPrintaspirinPill = true;
} // End if.
else
{
goPrintaspirinPill = false;
} // End else.
} // End aspirinPill.
void decongestantPill(string medTime, bool& goPrint) // Function determines if the enter time is a time required for a pill.
{
if (medTime == "1100" || medTime == "2000")
{
goPrintdecongestantPill = true;
} // End if.
else
{
goPrintdecongestantPill = false;
} // End else.
} // End decongestantPill.
void printReport(bool goPrintironPill, bool goPrintantibioticPill, bool goPrintaspirinPill, bool goPrintdecongestantPill) // Function displays to screen confirmation to take pill.
{
if (goPrintironPill = 1)
{
cout << "Time to take an Iron Pill." << endl;
} // End if.
if (goPrintantibioticPill = 1)
{
cout << "Time to take an Antibiotic Pill." << endl;
} // End if.
if (goPrintaspirinPill = 1)
{
cout << "Time to take an Aspirin Pill." << endl;
} // End if.
if (goPrintdecongestantPill = 1)
{
cout << "Time to take an Decongestant Pill." << endl;
} // End if.
} // End printReport.
|