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
|
#include <cstdlib>
#include<iostream>
#include <iomanip>
using namespace std;
void get_data(int& weight,int& heightInFeet,int& heightInInches);
float Hat_Size(int weight ,int heightInFeet ,int heightInInches);
int Jacket_Size(int,int,int);
int Waist_Size(int) ;
int main(int argc, char *argv[])
{
//declare weight, height_in_feet, height_in_inches of type int
int weight;
int height_in_feet;
int height_in_inches;
//declare hat result of type float
float hatSize;
//declare result of type int to hold the jacket size or waist size
int jacketSize;
int waistSize;
//declare type of operation of type char
char operation;
//Count for the loop
int count;
cout << "Please enter number of input sets : " ;
cin >> count;
cout << "Please enter the number of calculation sets you would like to perform: " << endl ;
//for loop based on the count
for (int i = 0; i < count; i++ )
{
// call get_data
get_data(weight, height_in_feet, height_in_inches);
// find hat size
hatSize = Hat_Size(weight, height_in_feet, height_in_inches);
// find jacket size
jacketSize = Jacket_Size(weight, height_in_feet, height_in_inches);
// find waist
waistSize = Waist_Size(weight);
// write result for all three cases
cout << setw(20) << "Hat Size : " << hatSize << endl;
cout << setw(20) << "Jacket Size : " << jacketSize << endl;
cout << setw(20) << "Waist Size : " << waistSize << endl;
if (i < count-1)
{
cout << endl << " Enter next calculation: " << endl ;
}
}
//endfor
cout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
//end of main //declare functions here, one void and three regular
void get_data(int& weight,int& heightInFeet,int& heightInInches)
{
//reads the weight, height in feet and height in inches
cin >> weight;
cin >> heightInFeet;
cin >> heightInInches;
}
float Hat_Size(int weight ,int heightInFeet ,int heightInInches)
{
float hatSize = ((float:weight * 2.9) / heightInInches;
return hatSize;
}
int Jacket_Size(int weight ,int heightInFeet ,int heightInInches)
{
return (weight * heightInInches / 288);
}
int Waist_Size(int weight)
{
return (weight/ 4.9);
}
|