Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "NumberArray.h"
- using namespace std;
- int main()
- {
- int inputSize;
- cout << "How many spaces should the array have?" << endl;
- cin >> inputSize;
- cout << endl;
- Class1 c1(inputSize);
- double inputNumber;
- for (int counter = 0; counter < inputSize; counter++)
- {
- cout << "Please enter a value for space " << counter + 1 << " in the array.\n";
- cin >> inputNumber;
- c1.storeNumber(inputNumber, counter);
- cout << endl;
- }
- double inputNumber1;
- int inputSlot1,
- inputSlot2;
- int menuChoice;
- for (int counter1 = 1; counter1 < 2;)
- {
- cout << "Enter a number to choose an action\n";
- cout << "1 Store a number\n";
- cout << "2 Retrieve a number\n";
- cout << "3 View highest number\n";
- cout << "4 View lowest number\n";
- cout << "5 View average of numbers\n";
- cout << "6 Exit program\n";
- cin >> menuChoice;
- if (menuChoice == 1)
- {
- cout << endl;
- cout << "Which space would you like to store the number in?\n";
- cin >> inputSlot1;
- inputSlot1 -= 1;
- cout << endl;
- cout << "What number would you like to store?\n";
- cin >> inputNumber1;
- cout << endl;
- c1.storeNumber(inputNumber1, inputSlot1);
- inputSlot1 +=1;
- cout << inputNumber1 << " has been stored in space " << inputSlot1 << ".\n\n";
- }
- else if (menuChoice == 2)
- {
- cout << endl;
- cout << "Which space would you like to retrieve a number from?\n";
- cin >> inputSlot2;
- inputSlot2 -= 1;
- cout << endl;
- cout << "The number is " << c1.getNumber(inputSlot2) << ".\n\n";
- }
- else if (menuChoice == 3)
- {
- cout << endl;
- cout << "The highest number in the array is " << c1.getHighest() << ".\n\n";
- }
- else if (menuChoice == 4)
- {
- cout << endl;
- cout << "The lowest number in the array is " << c1.getLowest() << ".\n\n";
- }
- else if (menuChoice == 5)
- {
- cout << endl;
- cout << "The average of all numbers from the array is " << c1.getAverage() << ".\n\n";
- }
- else if (menuChoice == 6)
- {
- counter1 = 2;
- cout << endl;
- }
- }
- }
Add Comment
Please, Sign In to add comment