CS 010 - Introduction to Computer Science I
Assignment 5: Apple Growing Experiment

DUE: Friday, February 20 before 11:00pm


Collaboration Policy

This programming assignment is designed in part for us to determine how well you are able to program. Thus, every part of the program should be your own original work, and should not be substantially similar to other students' code, as well code from books, previous solutions, the web, etc. Like other skills (e.g., surgery), the only way to really learn programming is to do it yourself. Some collaboration is O.K., including discussing the general solution method, and some debugging assistance after a student has tried hard to solve the bug him/herself. We DO encourage you to work with others nearby, so if you get stuck, you can get help. But, you should not show your code to another student in order to help that student. For this assignment, copying code from another source (e.g., copy-and-paste, reading off of another's monitor, etc.) is not considered appropriate collaboration and will have severe consequences.


Turn in online to the appropriate folder for your lab section (e.g., as5_20 for students enrolled in lab section 20). Your assignment may not get graded if it gets turned into the wrong section.

Remember to add your name, login, SID (last 4 digits), lecture and lab section numbers, and email address, to the header of your program


IMPORTANT:

You must turn in programming assignments as C++ source files. Spaces or non-alphanumeric characters in your filename may cause the turnin to not work. A good name for your file is as5.cpp.


Problem Definition:

Write a program that computes and outputs statistics for an experiment in apple growth. The program will read in data from one file and then compute and output statistics to two separate files.

There are two groups of apple trees that are being compared to each other, Group A and Group B. Each line of the input file will have data from one tree. The line will contain the name of the group the tree belongs to (A or B) followed by the weight in ounces of 10 apples picked at random from the tree. Your program will output the data for each tree into the appropriate output file along with the average weight of an apple for that tree. If the tree belongs to group A, your program should output its statistics to the file groupA.dat. If the tree belongs to group B, your program should output its statistics to the file groupB.dat. The input file may have any number of lines (trees).

You must use the following names for your data files:

     input file: input.dat
     output files: groupA.dat, groupB.dat

Finally, your program should output to the screen the average weight of an apple in each group.

The following is a sample run of the program using this input file, input.dat. Your program should produce output files that look like these when using this input file: groupA.dat, groupB.dat.

Sample:

     This program separates the data from an input file
     named input.dat into two output files, groupA.dat and
     groupB.dat.

     groupA.dat now holds the statistics for all apple
     trees in group A and groupB.dat now holds the
     statistics for all apple trees in group B.

     Average weight of an apple in Group A: 4.1397 ounces
     Average weight of an apple in Group B: 4.1085 ounces

Points:

For all remaining programming assignments, if your program does not compile it will not be graded and you will receive 0 points for that assignment.