//File: hw2soln.cpp
//A program to determine your chance of a heart attack and the number of miles
//you must run to not die
//
#include <iostream>
using namespace std;
int main()
{
const float AIR_QUAL = 5.6; // Air quality factor - describes air
// in the restaruant
const float KRUST_BURGER_MIT_FACTOR = 19.7; // the Krusty burger
// mitigation factor determines amount
// of exercise needed to not die
const int MARATHON_LENGTH = 26; //26 miles to the marathon
short numBurgers, numFries, numShakes, lenQueue; //input variables
float heartAtkPct; //calculated percent chance of heart attack
bool walkedIn;
float milesToRun;
int marathons;
// Welcome Message
cout << "\t\tWelcome to Krusty's Health Spa!" << endl << endl;
// Data Prompts
cout << "Please tell me, how many burgers did you order?\t";
cin >> numBurgers;
cout << endl << "And how many fries did you buy?\t";
cin >> numFries;
cout << endl << "How many milkshakes did you consume?\t";
cin >> numShakes;
cout << endl << "How many people were in line in front of you?\t";
cin >> lenQueue;
walkedIn = static_cast<bool>(numBurgers * numFries * numShakes);
// Calculate the percent chance of having a heart attack
heartAtkPct = (numBurgers + numFries) * (static_cast<float>(numShakes)
/ (lenQueue + 1)) + (walkedIn * AIR_QUAL);
cout << endl << "Your chance of a heart attack is " << heartAtkPct
<< "%. Better get running!" << endl;
// Figure out how far to run
milesToRun = heartAtkPct * KRUST_BURGER_MIT_FACTOR;
marathons = static_cast<int>(milesToRun / MARATHON_LENGTH);
cout << endl << "You must run " << marathons << " marathons ";
cout << "plus " << milesToRun - (marathons * MARATHON_LENGTH)
<< " miles to save your life! . . . good luck with that!" << endl;
return 0;
}