I am to write a program that determine the amount of cloth in square inches needed to make a certain kind of garment
The instructions state 'Rather than using one big pile of main( ), you need to use functions for these calculation that incorporate pass-by-value parameters. In addition, you need to include various int or double const declarations within your program. Finally, embed your program in a loop so that the calculation can be repeated as often as the user wishes. IN ORDER TO RECEIVE FULL CREDIT, YOU MUST DEFINE AND CALL FUNCTIONS AND PASS ARGUMENTS.'
Pants
2 1/2 square inch per waist size inch of the
person being fitted
1/2 square inch per height inch of the person
being fitted
1/10 square inch per waist size inch of the
person being fitted, if pleaded front is desired
If baggy look is desired, add an extra 10% to
the fabric amount calculated so far
Shirt
2 3/8 square inch per waist size inch of the
person being fitted
4/9 square inch per height inch of the person
being fitted
2 4/5 square inch per arms length inch of the
person being fitted, if long sleeves are desire
Shorts
1 3/10 square inch per waist size inch of the
person being fitted
1/4 square inch per height inch of the person
being fitted
If pockets are desired, add an extra 15% to the
fabric amount calculated so far
So far this is all I have...
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
|
#include <iostream>
using namespace std;
double fabric(double waist_size, double height_size);
int main()
{
const double pleat = 0.1;
double fabric_pants, waist_size, height_size;
char ans;
cout << "Welcome to the Pants Consumers Union.\n";
cout << "Gimme your waist size in inches: ";
cin >> waist_size;
cout << "Gimme your height size in inches: ";
cin >> height_size;
//cout << "Pleaded front? [Y/N]:";
//cin >> ans;
//while ((ans == 'Y') && (ans == 'y'));
//waist_size = waist_size + (pleat*waist_size);
fabric_pants = fabric(waist_size, height_size);
cout << "For your pants, you'll need "
<< fabric_pants
<< " square inches of fabric!" << endl;
return 0;
}
double fabric(double waist_size, double height_size)
{
const double waist = 2.5, height = 0.5;
double waist_fabric, height_fabric;
waist_fabric = waist_size*waist;
height_fabric = height_size*height;
return (waist_fabric + height_fabric);
}
|
The Output is "SUPPOSED" to be as follows
Tailor Fabric Calculator:
Whaddya want? [P]ants or [S]hirts or shor[T]s:
P
Gimme your waist size in inches:
30
Gimme your height size in inches:
72
Pleaded front? [Y/N]:
Y
Baggy Look? [Y/N]:
N
For your pants, you'll need 114 square inches of fabric!
Try again? [Y/N]:
Y
Tailor Fabric Calculator:
Whaddya want? [P]ants or [S]hirts or shor[T]s:
S
Gimme your waist size in inches:
32
Gimme your height size in inches:
50
Long sleeves? [Y/N]:
Y
Gimme your arms length in inches:
25
For your shirts, you'll need 168.2222 square inches of fabric!
Try again? [Y/N]:
Y
Tailor Fabric Calculator:
Whaddya want? [P]ants or [S]hirts or shor[T]s:
T
Gimme your waist size in inches:
35
Gimme your height size in inches:
72
Pockets? [Y/N]:
Y
For your shorts, you'll need 73.025 square inches of fabric!
Try again? [Y/N]:
N