Assignment 05

Due: Thursday, March 2, 2017 at noon 100 pts

Specifications: Your program is to do a bunch of stuff. But this time, it will do it using functions. Herein we will layout the functions you will use. Thus, you will have functions to do the following:

  • A greeting function. This function will be passed nothing. It will greet the user with a friendly message, and it will also prompt for and read in their name and return it.

  • A signoff function. Similarly, it will do nothing more than output to the screen a exiting message to the user. It will have one parameter of type string, the name of the user. Use the name in the message.

  • A function to prompt for and read from the user the waist measurement of a pair of pants. This value should be returned. The function should prevent input of negative values....for obvious reasons.

  • A function to prompt for and read in the user's leg length measurement (that's waist to floor). This value should be returned. The function should prevent input of negative values....for obvious reasons.

  • A function to prompt for and read in the user's high-water tolerance measurement (that's floor to bottom of pant's cuff). This value should be returned. The function should prevent input of negative values....for obvious reasons.

  • A function that will be passed the pant's waist measurement and it will return an inseam measurement (that's the length of a pant leg, waist to bottom of cuff). This is computed by multiplying the waist by the constant mentioned in the background section above.

  • A function that will be passed the user's leg length and high-water tolerance measurements, and the calculated inseam from the previous function. It will then subtract the computed inseam from the leg length to determine the pant's high-water value, compare it to the user's high-water tolerance, and return true if this calculated value for high-water pants is greater than or equal to the user's tolerance or false if it is less (ppffft! pants too long).

  • A function that is passed the true/false value from the previous function. It will output "These pants are NOT high-water enough for you" if input is false, and "Great pair of high-waters!" if input is true.

Thus, your program will greet the user, get their name, retrieve measurements from the user, compute inseam, and finally inform the user as to the suitability of the pants they are considering buying. It should then prompt the user to repeat the whole process again (for a different pair of trousers), and repeat all this until they decline. At that point, the signoff message is issued.

Details: Be sure to use all the good programming practices that we've taught you:

  • good formatting of the code

  • good commenting

  • good variable and function names

  • use of constants

  • friendly prompts and outputs

When you submit: As usual, when you submit, cssubmit will compile and run your program. Your inputs will be:

  • for name, just pick any name you like (but be sure not to have whitespace in the name)

  • enter 23 for waist measurement

  • enter -27 for length of leg

  • enter 27 for length of leg

  • enter 4 high-water tolerance

  • repeat

  • 25 for waist

  • 24 for leg

  • -4 for tolerance

  • 4 for tolerance

  • quit

And, as usual, don't hesitate to ask your instructor if you have any questions. And if it doesn't work out, you can always become a tailor....it's so easy!

Instructions: You know how to submit; do it in the usual way.Background: As everyone in the whole wide world knows, Milhouse wears "high-water pants". So when he and his mom go shopping for new pants, Milhouse has to be careful to buy proper pants; they have to have enough high-water-ness to them. So, they shop only at the best stores! If you aren't familiar with this kind of store, they work like this: You pick the type of cloth, the style and the color. Then you try on different pants. Once you find a pair that's right in these aspects, you settle on a waist measurement. Then the in-house tailor at the store will hem the legs to the right length. Now, what most people don't know is that the inseam (are your ready for a big lie?) is determined by multiplying the waist measure by the universally known waist-inseam ratio that all pant manufacturers use to determine inseam based on waist. You know, that's why pants fit ALL people regardless of shape. That value is 0.9.

And that is the true story of how Milhouse buys his pants.

"Everything is coming up Milhouse"