-
Notifications
You must be signed in to change notification settings - Fork 0
/
recursiveMain.cpp
68 lines (51 loc) · 1.49 KB
/
recursiveMain.cpp
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
66
67
68
#include "recursive.hpp"
int main()
{
Menu menu1;
InputValid inputValid1;
do
{
menu1.displayMenu();
menu1.setChoice();
// Passes a string to the reverseString function
if (menu1.getChoice() == 1)
{
cout << "Enter a string, I will print it in reverse!" << endl;
string str = inputValid1.isString();
reverseString(str);
}
// Asks for array size, creates dynamic array, and adds numbers to the array based on user input
if (menu1.getChoice() == 2)
{
cout << "How many integers would you like to find the sum of?" << endl;
int numOfInt = inputValid1.isPosInteger();
cout << "Enter the numbers you would like to sum, pressing enter after each number." << endl;
int *sumArray = new int[numOfInt];
for (int i = 0; i < numOfInt; i++)
{
int arrayNum = inputValid1.isPosInteger();
sumArray[i] = arrayNum;
}
int sum = 0;
sum = sumOfArray(sumArray, numOfInt);
cout << sum << endl;
// deletes the array
delete[] sumArray;
sumArray = NULL;
}
// Passes user input number to the triangularNum function
if (menu1.getChoice() == 3)
{
cout << "Enter a number and I will find the triangular number." << endl;
int numOfInt = inputValid1.isPosInteger();
int sum;
sum = 0;
sum = triangularNum(numOfInt);
cout << sum << endl;
}
// Exits program
} while (menu1.getChoice() != 4);
cout << "... Exiting program" << endl;
cin.get();
return 0;
}