// ConsoleApplication8.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include using namespace std; void calcConcrete(float a, float x, float y, float z, int b) { float realVolume; float water; realVolume = ((x * 0.5) + (y * 0.6) + (z * 0.6)); water = (x + y + z) * (static_cast(b) / 100); cout << "For " << a << "m3 of concrete with a proportion of " << x << ":" << y << ":" << z << " and " << b << "% of water you will need: " << endl; cout << "Cement:\t" << ((a * x) / realVolume) * 35.7 << "\t bags" << endl; cout << "Sand:\t" << (a * y) / realVolume << "\t m3" << endl; cout << "Gravel:\t" << (a * z) / realVolume << "\t m3" << endl; cout << "Water:\t" << (((a * water) / realVolume) * 1000) / 15 << "\t barrels" << endl; } void switchConcrete(int a, int b) { float x, y, z; switch (a) { case 1: x = 1; y = 1.5; z = 1.5; break; case 2: x = 1; y = 1.5; z = 2; break; case 3: x = 1; y = 1.5; z = 2.5; break; case 4: x = 1; y = 1.5; z = 3; break; case 5: x = 1; y = 2; z = 2; break; case 6: x = 1; y = 2; z = 2.5; break; case 7: x = 1; y = 2; z = 3; break; case 8: x = 1; y = 2; z = 3.5; break; case 9: x = 1; y = 2; z = 4; break; case 10: x = 1; y = 2.5; z = 2.5; break; case 11: x = 1; y = 2.5; z = 3; break; case 12: x = 1; y = 2.5; z = 3.5; break; case 13: x = 1; y = 2.5; z = 4; break; } float c; cout << "How much concrete are we calculating with a proportion of " << x << ":" << y << ":" << z << " and a percentage of " << b << "% of water?" << endl; cin >> c; calcConcrete(c, x, y, z, b); } void calcMortar(float a, float x, float y, int b) { float realVolume; float water; realVolume = ((x * 0.5) + (y * 0.6)); water = (x + y) * (static_cast(b) / 100); cout << "For " << a << "m3 of mortar with a proportion of " << x << ":" << y << " and " << b << "% of water you will need: " << endl; cout << "Cement:\t" << ((a * x) / realVolume) * 35.7 << "\t bags" << endl; cout << "Sand:\t" << (a * y) / realVolume << "\t m3" << endl; cout << "Water:\t" << (((a * water) / realVolume) * 1000) / 15 << "\t barrels" << endl; } void switchMortar(int a, int b) { float x, y; switch (a) { case 1: x = 1; y = 1; break; case 2: x = 1; y = 2; break; case 3: x = 1; y = 3; break; case 4: x = 1; y = 4; break; case 5: x = 1; y = 5; break; case 6: x = 1; y = 6; break; case 7: x = 1; y = 7; break; case 8: x = 1; y = 8; break; } float c; cout << "How much mortar are we calculating with a proportion of " << x << ":" << y << " and a percentage of " << b << "% of water?" << endl; cin >> c; calcMortar(c, x, y, b); } void showError() { cout << "\a"; cout << "Error: Invalid type!" << endl; } void showExit() { cout << "\a"; cout << "Error: Something went terrible wrong, exiting..." << endl; // exit stuff here } void askWater(int x, bool y) { int b; cout << "Which percentage of water are we using? (10, 15 or 20 recommended)" << endl; cin >> b; if (y) { switchConcrete(x, b); } else if (!y) { switchMortar(x, b); } else { showExit(); } } void showConcrete() { int x; bool concrete = true; cout << "Choose your concrete type:" << endl << endl; cout << "# \t VOLUMETRIC RATIO \t \t RESISTANCE AT 28 days (kg/cm2)" << endl; cout << "1 \t 1:1.5:1.5 \t \t \t 303" << endl; cout << "2 \t 1:1.5:2 \t \t \t 270" << endl; cout << "3 \t 1:1.5:2.5 \t \t \t 245" << endl; cout << "4 \t 1:1.5:3 \t \t \t 230" << endl; cout << "5 \t 1:2:2 \t \t \t \t 217" << endl; cout << "6 \t 1:2:2.5 \t \t \t 195" << endl; cout << "7 \t 1:2:3 \t \t \t \t 165" << endl; cout << "8 \t 1:2:3.5 \t \t \t 164" << endl; cout << "9 \t 1:2:4 \t \t \t \t 140" << endl; cout << "10 \t 1:2.5:2.5 \t \t \t 156" << endl; cout << "11 \t 1:2.5:3 \t \t \t 147" << endl; cout << "12 \t 1:2.5:3.5 \t \t \t 132" << endl; cout << "13 \t 1:2.5:4 \t \t \t 118" << endl; cin >> x; if (x <= 13) { askWater(x, concrete); } else { showError(); showConcrete(); } } void showMortar() { int x; bool concrete = false; cout << "Choose your mortar type:" << endl << endl; cout << "# \t VOLUMETRIC RATIO \t \t USES" << endl; cout << "1 \t 1:1 \t \t \t \t Finishing" << endl; cout << "2 \t 1:2 \t \t \t \t Finishing" << endl; cout << "3 \t 1:3 \t \t \t \t Plaster" << endl; cout << "4 \t 1:4 \t \t \t \t Plaster" << endl; cout << "5 \t 1:5 \t \t \t \t Plaster" << endl; cout << "6 \t 1:6 \t \t \t \t Glue" << endl; cout << "7 \t 1:7 \t \t \t \t Glue" << endl; cout << "8 \t 1:8 \t \t \t \t Glue" << endl; cin >> x; if (x <= 8) { askWater(x, concrete); } else { showError(); showMortar(); } } void typeSelection() { int x; cout << "What do you want to calculate?" << endl; cout << "1. Concrete" << endl; cout << "2. Mortar" << endl; cin >> x; if (x == 1) { showConcrete(); } else if (x == 2) { showMortar(); } else { showError(); typeSelection(); } } int main() { typeSelection(); cin.ignore(); cin.clear(); cin.get(); return 0; }