Print Name __________________________
Signature __________________________
Dynamic Array I Lab
Individual Assignment
40 Points
2] Class Shall be called IntArray. The first array element
filled shall be element 1. Do not use element 0 at any time in this
program!
| class IntArray
{ public: IntArray(long int NewMax = 10);private: long int Max, ActNo; int *Array; }; |
3] The two displays written in class are listed below. The
second was mailed to you. Be able to duplicate either without looking at the
code.
| void IntArray::QuickAndDirtyDisplay (char Message[]) { long int Pos; if (strlen(Message) > 0) cout << Message << endl; if (ActNo == 0) cout << "\n Array Is Empty!\n\n"; for (Pos = 1; Pos <= ActNo; Pos ++) { cout << setw(10) << Array[Pos]; if (Pos % 10 == 0) cout << endl; } cout << endl << "ActNo = " << ActNo << " Max = " << Max << "\n\n"; } void IntArray::Display (char Message[], long int NoToDisplay) { long int Subscript; if (strlen(Message) > 0) cout << Message << endl; if (ActNo == 0) cout << "\n Array Is Empty!\n\n"; if (NoToDisplay > 0) { if (NoToDisplay <= 0) NoToDisplay = ActNo; if (NoToDisplay > Max) NoToDisplay = Max; for (Subscript = NoToDisplay; Subscript >= 1; Subscript --) { cout << " --------------------\n"; cout << setw(6) << Subscript << " | " << setw(16) << Array[Subscript]; cout << " |\n"; } cout << " --------------------\n"; } cout << " ActNo = " << ActNo << " Max = " << Max << endl << endl << endl; } |
4] With the exception of the Stats method, you know the functionality of all of the modules from lecture and previous labs. Output from the Stats module would be as follows: {It shall call QuickAndDirtyDisplay, High, Low, Sum, Average --- Make sure you include the dotted lines!}
------------------------------------------------------------------------
Stats for Module Nos Message
------------------------------------------------------------------------
Data:
1
2
1
3
1 1
ActNo = 6 Max = 100
Low = 1
High = 3
Sum = 9
Average = 1.5
------------------------------------------------------------------------
5] Write a module, called TestInArray, which shall do the following:
6] Each and every program file that you turn in this semester
shall contain a documentation block at the top. Document yours!
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
///
xxxxxxx.cpp
//
///
//
/// Purpose :
//
///
//
/// Written By : Dr. Thomas E. Hicks
Environment : Linux //
/// Date
: 9/10/00
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
7] The following line of code will execute your program and send the output to a file called Output.txt . Although you will not be able to see the prompts, enter the data specified above.
a.out > Output.txt
8] Start Windows 2000/NT/98/95
Use a Word Processor/Editor to print your programs. Set the left margin to 1 " and the right margin to .5". Make the font Courier 10 or New Courier 10. Print PrimeNo.cpp. Print Output.txt.
9] Copy files DynamicArrays1.cpp and Output.txt to a floppy
disk. Copy files DynamicArrays1.cpp and Output.txt to a second floppy
disk. Keep one of these disks as a backup.
A] Divider
B] Copy of this assignment sheet. Using an ink pen, print your name and sign this lab at the top.
C] Output.txt printout.
D] DynamicArrays1.cpp printout.
E] Disk containing the files.