Exercise #2
Suppose that I have an apple tree and I decide to give away the fruit to my neighbors. I have collected 386 apples and I have 13 neighbors. For this exercise, you are to write a program that specifies the number of apples is constant (386) and the number of neighbors is constant (13). Have the program calculate the number of apples I should give to each neighbor, assuming that I give each the same number. Note: I will give only whole apples to each neighbor, no partial apples.
The program should calculate the number of apples to give and output it in a message that looks like this:
With 386 apples and 13 neighbors, give each neighbor <result> apples.
where <result> is the value of a variable that is computed by your program. You must use named constants for the numbers of apples and neighbors and use these names everywhere in your program (including the output statements) to make the program easy to modify. Be sure to include appropriate comments in your program, choose meaningful identifiers, and use indentation as illustrated in the book and Programming Project #1.
Optional: Have the program display a second line identifying the number of apples I will have left over after giving those to my neighbors.
You are to develop this program in a team with two other members of the class. Be sure to identify all members of the team in your comments - one program per team. The name of the .cpp file should be based on the initials of the team members. When you are finished with the program, copy the .cpp file to the folder,
Z:\jlwolfe\cosc110\secX\ex2\
where X is 1 or 2, based on your section. Because we did not cover all the C++ you need to do this before today, you (and your team) may have many questions about what to do. Ask whatever you want and I will tell you what you need to do.
If you do not finish the program
by the time class is over, save what you have in a .cpp file and copy that
to the folder specified above.
Note: You need to start this project
(and all future projects) just like we did exercise #1. That is,
1) make a folder on the C: drive (if you don't already have one); 2) Build
a new project in that folder and name it after your team; 3) Make
the .cpp file for the project and name it after the team; 4) Compile,
link and run the program; and when finished, 5) Get out of Visual Studio
and copy the .cpp file to the Z: drive as described above.