Modified some project files, added gitignore

+- Modified Project_2.c to reflect more towards the assignment
++ Added a gitignore to stop exe files from being uploaded.
This commit is contained in:
Charles Descamps 2022-09-14 09:53:28 -07:00
parent bae201d85b
commit 978fe59a26
2 changed files with 109 additions and 41 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# exclude .exe files from being tracked.
*.exe

View file

@ -36,17 +36,20 @@ void printTopLine();
// main program // main program
int main() int main()
{ {
// Define Variables Needed: desiredArea (int) actualArea (int) houseWidth (int) houseDepth (int) // Define Variables Needed:
// roofingCost (double) plywoodCost (double) twoByFourCost (double) drywallCost (double) //desiredArea (int) actualArea (int) houseWidth (int) houseDepth (int)
// totalEstimate (double) // roofingCost (double) plywoodCost (double) twoByFourCost (double)
// drywallCost (double) totalEstimate (double)
int desiredArea, actualArea, houseWidth, houseDepth; int desiredArea, actualArea, houseWidth, houseDepth;
double roofingCost, plywoodCost, twoByFourCost, drywallCost, totalEstimate; double roofingCost, plywoodCost, twoByFourCost, drywallCost, totalEstimate;
// Print the house cost estimator headline // Print the house cost estimator headline
printString("House Cost Estimator"); printString("House Cost Estimator");
// Then print a blank line for formatting.
printEndline(); printEndline();
// Print a dividing line, use printCharacters(). // Print a dividing line, use printCharacters().
// Literal used since no constants can be created, and no standard found.
printCharacters(20, '='); printCharacters(20, '=');
// Print 2 blank lines for formatting nicely. // Print 2 blank lines for formatting nicely.
@ -54,30 +57,48 @@ int main()
// Ask user for input about the desired floor sq.ft.-age. // Ask user for input about the desired floor sq.ft.-age.
desiredArea = promptForInteger("Enter the desired floor square footage: "); desiredArea = promptForInteger("Enter the desired floor square footage: ");
// Then print a blank line for formatting.
printEndline();
// Calculate the house width(2/3 rounded of the area) (formula: sqrt((desiredSQFT/0.67))) // Calculate the house width(2/3 rounded of the area)
// then divide by trimmed value, cast to int, and then multiply by trimmed value to get result. //(formula: sqrt((desiredArea/SIDE_WALL_RATIO)))
houseWidth = ((findSquareRoot(desiredArea/SIDE_WALL_RATIO)) + BOOSTING_VALUE); // then divide by trimmed value, cast to int,
// and then multiply by trimmed value to get result.
houseWidth = desiredArea/SIDE_WALL_RATIO;
houseWidth = ((findSquareRoot(houseWidth)) + BOOSTING_VALUE);
houseWidth = houseWidth / TRIMMING_VALUE; houseWidth = houseWidth / TRIMMING_VALUE;
houseWidth = (int) houseWidth * TRIMMING_VALUE; houseWidth = (int) houseWidth * TRIMMING_VALUE;
printEndline();
// Calculate the house depth(1/3 rounded of the area) (formula: desiredArea/houseWidth) // Calculate the house depth(1/3 rounded of the area)
houseDepth = desiredArea / houseWidth; // (formula: desiredArea/(1/SIDE_WALL_RATIO))
houseDepth = desiredArea/(1/SIDE_WALL_RATIO);
houseDepth = ((findSquareRoot(houseDepth)) + BOOSTING_VALUE);
houseDepth = houseDepth / TRIMMING_VALUE;
houseDepth = (int) houseDepth * TRIMMING_VALUE;
// Calculate the actual area (houseWidth * houseDepth) // Calculate the actual area (houseWidth * houseDepth)
actualArea = houseWidth * houseDepth; actualArea = houseWidth * houseDepth;
// Calculate the roofing cost(using the equation provided on BBLearn) // Calculate the roofing cost(using the equation provided on BBLearn)
roofingCost = actualArea * ROOFING_PRICE; roofingCost = actualArea * ROOFING_PRICE;
// Calculate the plywood cost(sums up all the walls and floors of the house.)
plywoodCost = ((houseWidth * HOUSE_HEIGHT) + (houseWidth * HOUSE_HEIGHT)) * PLYWOOD_PRICE; // Calculate the plywood cost
plywoodCost = plywoodCost + ((houseDepth * HOUSE_HEIGHT) + (houseDepth * HOUSE_HEIGHT)) * PLYWOOD_PRICE; // (sums up all the walls and floors of the house.)
plywoodCost = ((houseWidth * HOUSE_HEIGHT)
+ (houseWidth * HOUSE_HEIGHT)) * PLYWOOD_PRICE;
plywoodCost = plywoodCost + ((houseDepth * HOUSE_HEIGHT)
+ (houseDepth * HOUSE_HEIGHT)) * PLYWOOD_PRICE;
plywoodCost = plywoodCost + (houseWidth * houseDepth) * PLYWOOD_PRICE; plywoodCost = plywoodCost + (houseWidth * houseDepth) * PLYWOOD_PRICE;
// Calculate the 2x4 cost(using the equation provided on BBLearn) // Calculate the 2x4 cost(using the equation provided on BBLearn)
twoByFourCost = (NUM_2x4_PER_FOOT * houseWidth); twoByFourCost = (NUM_2x4_PER_FOOT * houseWidth);
twoByFourCost = twoByFourCost + (NUM_2x4_PER_FOOT * houseDepth); twoByFourCost = twoByFourCost + (NUM_2x4_PER_FOOT * houseDepth);
twoByFourCost = twoByFourCost * TWO_BY_FOUR_PRICE; twoByFourCost = twoByFourCost * TWO_BY_FOUR_PRICE;
// Calculate the drywall cost(using the equation provided on BBLearn) // Calculate the drywall cost(using the equation provided on BBLearn)
drywallCost = (((houseWidth * HOUSE_HEIGHT)*2) + ((houseDepth * HOUSE_HEIGHT)*2)) * DRYWALL_PRICE; drywallCost = (((houseWidth * HOUSE_HEIGHT)*2)
+ ((houseDepth * HOUSE_HEIGHT)*2)) * DRYWALL_PRICE;
// Calculate the Total Estimate cost(add up using the previous values) // Calculate the Total Estimate cost(add up using the previous values)
totalEstimate = roofingCost + plywoodCost + twoByFourCost + drywallCost; totalEstimate = roofingCost + plywoodCost + twoByFourCost + drywallCost;
@ -85,6 +106,7 @@ int main()
printEndline(); printEndline();
// Print a dividing line, use the printTopLine(). // Print a dividing line, use the printTopLine().
// Then print a blank line for formatting.
printTopLine(); printTopLine();
printEndline(); printEndline();
@ -103,108 +125,153 @@ int main()
printEndline(); printEndline();
// Printed output of the desired area // Printed output of the desired area
// Uses functions printCharacter, printStringJustified,
// printIntegerJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" Desired Area", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("Desired Area", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printIntegerJustified(desiredArea, VALUE_WIDTH, "RIGHT"); printIntegerJustified(desiredArea, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" sq ft", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("sq ft", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the actual area, using the houseWidth * houseDepth // Printed output of the actual area, using the houseWidth * houseDepth
// Uses functions printCharacter, printStringJustified,
// printIntegerJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" Actual Area", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("Actual Area", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printIntegerJustified(actualArea, VALUE_WIDTH, "RIGHT"); printIntegerJustified(actualArea, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" sq ft", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("sq ft", UNIT_WIDTH -1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the house's width // Printed output of the house's width
// Uses functions printCharacter, printStringJustified,
// printIntegerJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" House Width", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("House Width", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printIntegerJustified(houseWidth, VALUE_WIDTH, "RIGHT"); printIntegerJustified(houseWidth, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" feet", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("feet", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the house's depth // Printed output of the house's depth
// Uses functions printCharacter, printStringJustified,
// printIntegerJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" House Depth", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("House Depth", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printIntegerJustified(houseDepth, VALUE_WIDTH, "RIGHT"); printIntegerJustified(houseDepth, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" feet", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("feet", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the roofing cost // Printed output of the roofing cost
// Uses functions printCharacter, printStringJustified,
// printIntegerJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" Roofing Cost", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("Roofing Cost", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printDoubleJustified(roofingCost, PRECISION, VALUE_WIDTH, "RIGHT"); printDoubleJustified(roofingCost, PRECISION, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" dollars", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("dollars", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the plywood cost // Printed output of the plywood cost
// Uses functions printCharacter, printStringJustified,
// printDoubleJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" Plywood Cost", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("Plywood Cost", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printDoubleJustified(plywoodCost, PRECISION, VALUE_WIDTH, "RIGHT"); printDoubleJustified(plywoodCost, PRECISION, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" dollars", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("dollars", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the 2x4 cost // Printed output of the 2x4 cost
// Uses functions printCharacter, printStringJustified,
// printDoubleJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" 2 X 4 Cost", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("2 X 4 Cost", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printDoubleJustified(twoByFourCost, PRECISION, VALUE_WIDTH, "RIGHT"); printDoubleJustified(twoByFourCost, PRECISION, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" dollars", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("dollars", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the drywall cost // Printed output of the drywall cost
// Uses functions printCharacter, printStringJustified,
// printDoubleJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" Drywall Cost", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("Drywall Cost", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printDoubleJustified(drywallCost, PRECISION, VALUE_WIDTH, "RIGHT"); printDoubleJustified(drywallCost, PRECISION, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" dollars", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("dollars", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
printEndline(); printEndline();
// Printed output of the Total Estimate // Printed output of the Total Estimate
// Uses functions printCharacter, printStringJustified,
// printDoubleJustified, printLightDividedLine, and printEndline
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" Total Estimate", DESCRIPTION_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("Total Estimate", DESCRIPTION_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printDoubleJustified(totalEstimate, PRECISION, VALUE_WIDTH, "RIGHT"); printDoubleJustified(totalEstimate, PRECISION, VALUE_WIDTH - 1, "RIGHT");
printCharacter(SPACE);
printCharacter(PIPE); printCharacter(PIPE);
printStringJustified(" dollars", UNIT_WIDTH, "LEFT"); printCharacter(SPACE);
printStringJustified("dollars", UNIT_WIDTH - 1, "LEFT");
printCharacter(PIPE); printCharacter(PIPE);
printEndline(); printEndline();
printLightDividedLine(); printLightDividedLine();
@ -330,4 +397,3 @@ void printTopLine()
// function: printCharacters // function: printCharacters
printCharacters( TABLE_WIDTH, THIN_LINE ); printCharacters( TABLE_WIDTH, THIN_LINE );
} }