Assignment 05

Specifications: You are to write this program using functions as prescribed here. The program should issue a greeting, prompt the user to input the names and weights of two fruits, report which one weighs more (and will, hence, win a race), then repeat the process as long as the user desires. You are to include the following:

  1. a function for greeting the user

  2. a function for sign-off to signal the termination of the program

  3. functionality to prompt for and read in the names and weights of two fruits. This can be done in several ways. You can do it with one function to get all four pieces of information or you can use two functions twice to get the info. You decide.

  4. a function to which will be passed both names and weights, and it will output to the screen the name and weight of the heavier fruit, claiming it will win any race with the other fruit. I think it should also say "GO FRUIT_NAME!" with the name of the heavier fruit in place of FRUIT_NAME.

GO BANANA!

Note: This is a fairly simple programming assignment. But it's your first using functions, so be careful and get started early. Of course, being a fairly easy assignment, you will HAVE MORE TIME TO PAY ATTENTION TO

    • CONSTANTS (note: no fruit has ever weighed more than 2000 lbs.)

    • GOOD VARIABLE NAMES

    • FORMATTING OF YOUR CODE

.....and don't forget to check for valid user inputs (always).

Also note, when you use cin to input a string type variable, it will only read in up to the first whitespace. That means that if you wish successful input of a fruit name, you better not have spaces in the name. Make sure your fruit names are only one word. Thus, "ugli fruit", "passion fruit", "canary melon", "goji fruit", and "Purple Mangosteen" are off limits.

GO BANANA!

When you submit: You may enter any fruit name and weight you wish, but run the functionality twice and then quit.

GO BANANA!

Remember: if you have any questions, be sure to ask. If you are in section A or B, ask this guy; if you are in section C or D, ask this one.

To see a demonstration of the aforementioned activity, just click on the picture to the right. -->

Background: When on the bus on the way to school, the Springfield youngsters like to take advantage of the occasional bus stop on a hill, whereby the kids will extract pieces of fruit from their lunch boxes and "race" them down the center aisle of the bus. Of course, the desire is for your fruit to make it to the emergency door at the back of the bus before the other guy's fruit. In the heat of the excitement, you will yell "GO ORANGE!" or "GO APPLE!" as your lunch careens down the runway of honor, reward, and stature in the community. Well, Ralph has never had much luck with his attempts at manhood rolling bunches of grapes, bananas, and kumquats on the bus. So, he wishes you to write a program to help him predict which piece of fruit will win a race. He assumes that a fruit that weighs more will go faster. Oh Ralph.

Due: Wednesday, March 5, 2014 at noon 100 pts

Instructions: You know how to submit; do it in the usual way.

"GO BANANA!!"