CS1044

Virginia Tech Computer Science Department
Tom Plunkett
thplunk2@vt.edu

Team Assignment #2: Modify an Existing Software Program

Existing Software Program: ReverseList program

Dale Weems Headington Textbook P.595

Requirements

Overview: The original program used inputs from the keyboard and output to the monitor. We want to allow the user to choose how to enter inputs and display outputs.

1) Instead of using the keyboard to enter inputs, we want the user to be able to choose from one of three options: 1)to read an user-selected input file; 2) to generate a sequence of numbers automatically (i.e. 1 through 1000); or 3) to use the keyboard to enter the inputs.

2) Instead of sending the output to the monitor, we want to prompt the user to select between 1) sending the output to the monitor; 2) sending the output to a user-named file; or 3) both 1 and 2.

3) When reading or writing to files, the program should prompt the user to enter the name of the file to be opened.

4) Identify all functions that need to be modified and the modifications that need to be made. If new functions need to be written, then specify the parameters, the definition, etc.

//The ReverseList program, reprinted from p.595 in Dale Weems Headington

#include <iostream.h>

int main() {

int value[1000];

int number;

for (number=0; number < 1000; number++) cin >> value[number];

for (number=999;number>=0;number--) cout << value[number] << endl;

return 0;

}

 

SAMPLE ANSWERS

team2a.cpp

team2b.cpp

team2c.cpp

team2d.cpp

team2e.cpp