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 145 146 147 148 149 150 151
|
/******************************************************************************************/
/* */
/* Programmer: Jason Smith */
/* */
/* CSC 134 --> C++ Programming */
/* */
/* non-Chapter Homework */
/* */
/* Program 4 */
/* */
/******************************************************************************************/
// Program Headers/Libraries
#include <iostream>
#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;
struct building
{
double length;
double width;
double height;
}unit;
////////// /* Function Prototypes */ //////////
double calc_area(double unit);
double num_wins(double &total);
double calc_BTU(double unit);
//////////////////// /* Main body of program */ ////////////////////
int main()
{
//Variables Used in Program
std::string name, grade;
double coats, brush, gallon, grand, total, negative, window, BTU=0;
double *ptr;
building *ptr;
//Obtain User Data
cout<<"Welcome, Please enter your FIRST NAME: ";
cin>>name;
system("CLS"); //Clear Screen and start with new page.
cout<<"Thank you "<<name<<".\n\n***** We are now ready for your buildings measurements. *****\n";
cout<<"Please enter the length in feet. "; cin>>unit.length;
cout<<"Please enter the width in feet. "; cin>>unit.width;
cout<<"Please enter the height in feet. "; cin>>unit.height;
cout<<"\n\n***** Now we need to know how many coats of paint will be applied. ******\n";
cout<<"Please enter the number of coats that will be applied. "; cin>>coats;
system("CLS"); // Clears screen for a new page again.
//Calling Functions and Performing Other Calculations
total = calc_area(*ptr);
window = num_wins(total);
BTU = calc_BTU(*ptr);
negative = total-(window * 18);
grand = negative*coats;
brush = ceil(grand/1100);
gallon = ceil(grand/325);
//Determine the Cooling Unit Class.
if (BTU > 0 && BTU < 14500)
{
grade = "A";
}
else if (BTU >= 14501 && BTU <= 29500)
{
grade = "B";
}
else if (BTU >= 29501 && BTU <= 45000)
{
grade = "C";
}
else if (BTU >= 45001 && BTU <= 61000)
{
grade = "D";
}
else if (BTU >= 61001 && BTU <= 75000)
{
grade = "E";
}
else if (BTU >= 75001 && BTU <= 100000)
{
grade = "F";
}
else if (BTU >= 100001)
{
grade = "G";
}
//Display all results to User.
cout<<"Thank you "<<name<<". Here is your list of supplies.\n\n";
cout<<"Total surface area: "<<negative<<"sqft"<<endl;
cout<<"Number of coats: "<<coats<<endl;
cout<<"Number of brushes required: "<<brush<<endl;
cout<<"Gallons of paint required: "<<gallon<<endl;
cout<<"Number of windows needed: "<<window<<endl;
cout<<"The BTUs required to cool the unit are: "<<BTU<<endl;
cout<<"Your recommended Cooling Unit is Grade "<<grade<<"."<<endl;
cout<<endl;
system("PAUSE");
return 0;
}
//////////////////// /* Function for calculating surface area. */ ////////////////////
double calc_area(double building)
{
double wall1, wall2, wall3, wall4, total;
wall1 = unit.length*unit.height;
wall2 = unit.length*unit.height;
wall3 = unit.width*unit.height;
wall4 = unit.width*unit.height;
total = wall1+wall2+wall3+wall4;
return total; //return variable 'total'
}
//////////////////// /* Function for calculating number of windows. */ ////////////////////
double num_wins(double &total)
{
double window;
window = ceil(total/150);
if ((int)(window) %2==0) // Cast double as int to check for mod 2 remainder of zero and if a remainder is present, it will add 1 to window.
{
window = window;
}
else
{
window++;
}
return window; //return variable 'window'
}
//////////////////// /* Function for calculating number of BTUs. */ ////////////////////
double calc_BTU(double building)
{
double cubicArea, BTU;
cubicArea = (unit.length * unit.height * unit.width);
BTU = cubicArea/1000;
return BTU;
}
|