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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
//------------------------------------------------------------------------------
//Programmer: Jennifer Preuss Student ID: 18159635
//Program: #5 Filename: program5.cpp
//Due: 4/2/18 Class: CS1971
//------------------------------------------------------------------------------
//Program Description
//This program takes input from the user in the form of height or length in feet
//converts it to inches, and then calculates the maximum allowable deflection.
//
#include <iostream>
using namespace std;
void Welcome();
char Measure(char beamtype);
void UserInput(float& Length_Height);
bool Verify(float Length_Height);
bool Verify2(char beamtype);
float Conversion(float Length_Height);
void Dmax1(float Length_Height, char beamtype);
void Dmax2(float Length_Height, char beamtype);
void Dmax3(float Length_Height, char beamtype);
void Dmax4(float Length_Height, char beamtype);
char RunAgain();
int main()
{
char beamtype;
char useranswer;
float Length_Height;
do
{
Welcome();
UserInput(Length_Height);
Measure(beamtype);
Conversion(Length_Height);
Dmax1(Length_Height, beamtype);
Dmax2(Length_Height, beamtype);
Dmax3(Length_Height, beamtype);
Dmax4(Length_Height, beamtype);
useranswer = RunAgain();
}while(useranswer == 'Y' || useranswer == 'y');
return 0;
}
void Welcome()
{
cout << "Welcome to the max deflection calculator!" << endl;
}
void UserInput(float& Length_Height)
{
bool Verification;
do
{
cout << "Please enter your value of beam length or height." << endl;
cin >> Length_Height;
Verification = Verify(Length_Height);
if(!Verification)
{
cout << "Invalid input." << endl;
cout << "Please enter a number greater than 10.";
}
}while(!Verification);
}
char Measure()
{
char beamtype;
bool Verification2;
do
{
cout << "Please indicate the type of structual element." << endl;
cout << " 'I' for interior, 'E' for exterior, 'R' for roof, 'A' for other: ";
cin >> beamtype;
cout << "here is beamtype: " << beamtype << endl;
Verification2 = Verify2(beamtype);
if(!Verification2)
{
cout << "Invalid input." << endl;
cout << "Please enter either 'I', 'E', 'R', or 'A' ";
}
}while(!Verification2);
return(beamtype);
}
bool Verify(char beamtype)
{
if((beamtype == 'I' || beamtype == 'i' || beamtype == 'E' || beamtype == 'e' || beamtype == 'R' || beamtype == 'r' || beamtype == 'A' || beamtype == 'a'))
{
return true;
}
else
{
return false;
}
}
bool Verify(float Length_Height)
{
if(Length_Height <= 10)
{
return false;
}
else
{
return true;
}
}
float Conversion(float Length_Height)
{
const int ruler = 12;
Length_Height = Length_Height * ruler;
return(Length_Height);
}
void Dmax1(float Length_Height, char beamtype)
{
float dmaxoutput;
const int num1 = 180;
if (beamtype == 'I' || beamtype == 'i')
{
dmaxoutput = Length_Height / num1;
cout << "The maximum allowable deflection is: " << dmaxoutput << endl;
}
}
void Dmax2(float Length_Height, char beamtype)
{
float dmaxoutput;
const int num1 = 360;
if (beamtype == 'E' || beamtype == 'e')
{
dmaxoutput = Length_Height / num1;
cout << "The maximum allowable deflection is: " << dmaxoutput << endl;
}
}
void Dmax3(float Length_Height, char beamtype)
{
float dmaxoutput;
const int num1 = 180;
if (beamtype == 'R' || beamtype == 'r')
{
dmaxoutput = Length_Height / num1;
cout << "The maximum allowable deflection is: " << dmaxoutput << endl;
}
}
void Dmax4(float Length_Height, char beamtype)
{
float dmaxoutput;
const int num1 = 240;
if (beamtype == 'A' || beamtype == 'a')
{
dmaxoutput = Length_Height / num1;
cout << "The maximum allowable deflection is: " << dmaxoutput << endl;
}
}
char RunAgain()
{
char useranswer;
cout << "Would you like to use the program again? 'Y' or 'N' ?";
cin >> useranswer;
return(useranswer);
}
|