-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriver.cpp
More file actions
65 lines (62 loc) · 4.11 KB
/
Driver.cpp
File metadata and controls
65 lines (62 loc) · 4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Preprocessor directives required for the Driver.cpp file
#include "Driver.h"
#include <iostream>
#include <cstdlib>
using namespace std;
// MAIN FUNCTION -- The primary driver of the program that uses the classes and checks if everything works properly
int main()
{
arrayFloat defaultArray; // Creates a new object to represent the default constructor array
defaultArray.getElements(); // Displays current status of default constructor array
cout << endl; // Format
int defaultY; // Declares int to be used as user input for choosing an element to store a new number
float defaultNumber; // Declares float to represent new number
cout << "Choose an element 0-9: "; // Prompts user for element
cin >> defaultY; // Input here, ELEMENT desired
cout << "What float number do you want to replace it with?" << endl; // Prompt user for new number
cin >> defaultNumber; // Input here, number
defaultArray.storeElement(defaultY, defaultNumber); // Calls the storeElement member function
defaultArray.getElements(); // Displays new status of default constructor array
cout << endl; // Format
cout << endl; // Format
int defaultIndex; // Declares int to represent the element the user types to retrieve the number
cout << "Type an element 0-9 to retrieve the number: "; // Prompt user for element
cin >> defaultIndex; // Input element here
cout << endl; // Format
defaultArray.retrieveNumber(defaultIndex); // Calls the retrieveNumber function
cout << endl; // Format
cout << endl; // Format
cout << "The HIGHEST value: " << defaultArray.getHighestValue() << endl; // Displays highest value in array
cout << "The LOWEST value: " << defaultArray.getLowestValue() << endl; // Displays lowest value in array
cout << "AVERAGE of all numbers: " << defaultArray.getAverage() << endl; // Displays average of array
cout << endl; // Format
int overloaded_SIZE_Array; // Declares int to be the size of the overloaded constructor array
cout << "What size do you want the overloaded array to be?" << endl; // Prompts user for size of array
cout << "Size: "; // Format/Prompts user
cin >> overloaded_SIZE_Array; // Input size of overloladed constructor array
arrayFloat overloadedArray(overloaded_SIZE_Array); // Creates a object for the overloaded constructor array
overloadedArray.getElements(); // Displays current status of overlloaded constructor array
int overloadedY; // Declares int to be used as user input for choosing an element to store a new number
float overloadedNumber; // Declares float to represent new number
cout << endl; // Format
cout << "Choose an element 0-" << overloaded_SIZE_Array-1 << ": "; // Prompt user for element
cin >> overloadedY; // Input here, ELEMENT desired
cout << "What float number do you want to replace it with?" << endl; // Prompt user for new number
cin >> overloadedNumber; // Input here, number
overloadedArray.storeElement(overloadedY, overloadedNumber); // Calls the storeElement member function
cout << endl; // Format
overloadedArray.getElements(); // Displays new status of overloaded constructor array
cout << endl; // Format
cout << endl; // Format
int overloadedIndex; // Declares int to represent the element the user types to retrieve the number
cout << "Type an element 0-" << overloaded_SIZE_Array-1 << " to retrieve the number: "; // Prompt user for element
cin >> overloadedIndex; // Input element here
cout << endl; // Format
overloadedArray.retrieveNumber(overloadedIndex); // Calls the retrieveNumber function
cout << endl; // Format
cout << "The HIGHEST value: " << overloadedArray.getHighestValue() << endl; // Displays highest value in array
cout << "The LOWEST value: " << overloadedArray.getLowestValue() << endl; // Displays lowest value in array
cout << "AVERAGE of all numbers: " << overloadedArray.getAverage() << endl; // Displays average of array
cout << endl; // Format
return 0; // Returns 0 for int main function
}