Clothing size program has me racking my brain!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2008
Posts: 1
Reputation: espm1000 is an unknown quantity at this point 
Solved Threads: 0
espm1000 espm1000 is offline Offline
Newbie Poster

Clothing size program has me racking my brain!

 
0
  #1
Nov 10th, 2008
Hello everyone, I am new to computer science, and thus far this semester I have not needed any help in writing a program even though I am stuck with a professor who struggles to get a clear point across. He is a great guy and tries to make sure we understand the material, but he is so comfortable with the stuff that he forgets we are entry level programmers!

Anyways, he recently gave us a program to write that involves functions and procedures in order to find clothing size. Here is the writeup he gave us for the program.

1) Write a C++ program to calculate a person's hat size, jacket size, and waist size using functions and procedures.
Hat size = weight in lbs divided by height in inches, and all of that multiplied by 2.9
Jacket Size = height in inches times weight divided by 288
waist in inches = weight in lbs divided by 4.9
2)The input of the program will be one of the following characters. H will indicate hat size, J will indicate Jacket size, and W will indicate waist in inches, then enter the weight, followed by the height in feet and inches.

So far this is what I have, and I am stuck!

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void get_sentinel (char &);
  6. void get_data (int &, int &, int &);
  7. float Hat_Size (float, float, float);
  8. int Jacket_Size (int, int, int);
  9. int Waist_Size (int, int, int);
  10.  
  11. int main()
  12. {
  13. int weight, height_in_feet, height_in_inches;
  14. float hat;
  15. int jacket, waist;
  16. get_data (weight, height_in_feet, height_in_inches);
  17. char method;
  18.  
  19.  
  20. return 0;
  21. }
  22.  
  23. void get_data (int & weight, int & height_in_feet, int & height_in_inches)
  24. {
  25.  
  26. cout << "Please enter your height in feet." << endl;
  27. cin >> height_in_feet;
  28. cout << "Please enter your height in inches." << endl;
  29. cin >> height_in_inches;
  30. cout << "Please enter your weight." << endl;
  31. cin >> weight;
  32.  
  33. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,819
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Clothing size program has me racking my brain!

 
0
  #2
Nov 10th, 2008
Originally Posted by espm1000 View Post
Hello everyone, I am new to computer science, and thus far this semester I have not needed any help in writing a program even though I am stuck with a professor who struggles to get a clear point across. He is a great guy and tries to make sure we understand the material, but he is so comfortable with the stuff that he forgets we are entry level programmers!

Anyways, he recently gave us a program to write that involves functions and procedures in order to find clothing size. Here is the writeup he gave us for the program.

1) Write a C++ program to calculate a person's hat size, jacket size, and waist size using functions and procedures.
Hat size = weight in lbs divided by height in inches, and all of that multiplied by 2.9
Jacket Size = height in inches times weight divided by 288
waist in inches = weight in lbs divided by 4.9
2)The input of the program will be one of the following characters. H will indicate hat size, J will indicate Jacket size, and W will indicate waist in inches, then enter the weight, followed by the height in feet and inches.

So far this is what I have, and I am stuck!

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void get_sentinel (char &);
  6. void get_data (int &, int &, int &);
  7. float Hat_Size (float, float, float);
  8. int Jacket_Size (int, int, int);
  9. int Waist_Size (int, int, int);
  10.  
  11. int main()
  12. {
  13. int weight, height_in_feet, height_in_inches;
  14. float hat;
  15. int jacket, waist;
  16. get_data (weight, height_in_feet, height_in_inches);
  17. char method;
  18.  
  19.  
  20. return 0;
  21. }
  22.  
  23. void get_data (int & weight, int & height_in_feet, int & height_in_inches)
  24. {
  25.  
  26. cout << "Please enter your height in feet." << endl;
  27. cin >> height_in_feet;
  28. cout << "Please enter your height in inches." << endl;
  29. cin >> height_in_inches;
  30. cout << "Please enter your weight." << endl;
  31. cin >> weight;
  32.  
  33. }
  1. float Hat_Size (float, float, float);

Hat size = weight in lbs divided by height in inches, and all of that multiplied by 2.9
Look at your function prototype. It takes three parameters. Look at the description. It takes two parameters. These should match. Ditto with jacket size and waist size. Read the descriptions, decide what needs to be passed to the function in order for the function to do its job. If you don't need to pass something, don't pass it. Pick some variable names for these functions and try implementing them. Right now you declare them, but don't implement them, which means you can't call them. Just have them return 0 for the implementation for now, add the function calls, and get it to compile. Adding names to the variables will help you write the program.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC