Commit 81fc608f authored by dlmfxq's avatar dlmfxq
Browse files

hw1 1.27.21 main() complete

parent b9f58c1c
2021-SP-301-labs-dlmfxq @ 7579341a
Subproject commit 7579341a289b926b79726833d86cb9bb13105b35
File added
// Programmer: Daniel Martin
// MST Username: dlmfxq
// Instructor: Wong
// Section: 109
// Date: 01/27/2021
// File: hw1.cpp
// Description: Calculates optimal amount of sugar to keep gamblers going
//Including I/O stream library
#include<iostream>
using namespace std;
const float GUT_FEELING = 20;
const int AVG_SUGAR_CONSUMED = 2;
float num_people;
float avg_weight;
float lunch_money;
float lbs_sugar;
int num_duff_sodas;
bool include_SELM = false;
int main()
{
cout << "\t\t Welcome to Bart's Sugar Monster Calculator" << endl;
//Prompt for #people, their weight, lunch money index
cout << "\nPlease enter the following:" << endl;
cout << "\tNumber of gamblers:\t";
cin >> num_people;
cout << "\tTheir average weight:\t";
cin >> avg_weight;
cout << "\tLunch money index(SELM):";
cin >> lunch_money;
cout <<"Calculating..." << endl;
//Only include SELM if #people > 5
include_SELM = num_people > 5;
lunch_money *= include_SELM;
//Formula for lbs of sugar to keep gamblers going
//lbs sugar = #people * (avgWeight * (avgSugarConsumption/gut feeling)+SELM)
lbs_sugar = num_people * (avg_weight * (AVG_SUGAR_CONSUMED/GUT_FEELING)+lunch_money);
//Calculate duff soda equivalent (3 lbs sugar / duff soda"
num_duff_sodas = lbs_sugar / 3;
//Print results
cout << "\t" << lbs_sugar << " lbs. of sugar is needed for the day" << endl;
cout << "\tThis is equivalent to " << num_duff_sodas <<" bottle(s) of "
<< "Duff Soda" << endl;
cout << "\nHave a nice day!" << endl;
return 0;
}
File added
// Programmer: Daniel Martin
// MST Username: dlmfxq
// Instructor: Wong
// Section: 109
// Date: 01/27/2021
// File: hw1.cpp
// Description: Calculates optimal amount of sugar to keep gamblers going
//Including I/O stream library
#include<iostream>
using namespace std;
const float GUT_FEELING = 20;
const int AVG_SUGAR_CONSUMED = 2;
float num_people;
float avg_weight;
float lunch_money;
float lbs_sugar;
int num_duff_sodas;
bool include_SELM = false;
int main()
{
cout << "\t\t Welcome to Bart's Sugar Monster Calculator" << endl;
//Prompt for #people, their weight, lunch money index
cout << "\nPlease enter the following:" << endl;
cout << "\tNumber of gamblers:\t";
cin >> num_people;
cout << "\tTheir average weight:\t";
cin >> avg_weight;
cout << "\tLunch money index(SELM):";
cin >> lunch_money;
cout <<"Calculating..." << endl;
//Only include SELM if #people > 5
include_SELM = num_people > 5;
lunch_money *= include_SELM;
//Formula for lbs of sugar to keep gamblers going
//lbs sugar = #people * (avgWeight * (avgSugarConsumption/gut feeling)+SELM)
lbs_sugar = num_people * (avg_weight * (AVG_SUGAR_CONSUMED/GUT_FEELING)+lunch_money);
//Calculate duff soda equivalent (3 lbs sugar / duff soda"
num_duff_sodas = lbs_sugar / 3;
//Print results
cout << "\t" << lbs_sugar << " lbs. of sugar is needed for the day" << endl;
cout << "\tThis is equivalent to " << num_duff_sodas <<" bottle(s) of "
<< "Duff Soda" << endl;
cout << "\nHave a nice day!" << endl;
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment