View difference between Paste ID: ZjEgW3xj and 4Z421jKa
SHOW: | | - or go back to the newest paste.
1
//Eric Johnson
2
//04-16-12
3
//simple ARRAY
4
#include <iostream>
5
#include "screen.hpp"
6
using namespace std;
7
void intvalid (int* data) {  //For ints
8
while(cin.fail()) { //Input validation loop
9
   cin.clear();  //Clear flags
10
   cin.ignore(255,'\n');  //Clear input buffer
11
   cout<<"Invalid Input - Please input a number:";
12
   cin>>(*data);
13
   }
14
}
15
//enumerated type definition
16
17
18-
enum (p200_299,p300_399,p400_499,p500_599,p600_699,p700_799,p800_899,p900_999,p1000_over);
18+
19
{
20-
int response;
20+
enum {p200_299,p300_399,p400_499,p500_599,p600_699,p700_799,p800_899,p900_999,p1000_over};
21-
char run='y';
21+
22
for (int i=0; i<9; i++)
23
pay[i]=0;
24-
    response = screen(pay);
24+
string response;
25-
    intvalid(&response);
25+
cout << "Which pay range would you like to increment? (1-9): ";
26
do
27
{
28
cin >> response;
29
}
30
while (intvalid))
31
32
char run=NULL;
33
//implement as for loop
34
do{
35
    response=screen(pay);
36
    //intvalid(&response);
37
while (response != 1
38
     &&response != 2
39
     &&response != 3
40
     &&response != 4
41
     &&response != 5
42
     &&response != 6
43
     &&response != 7
44
     &&response != 8
45
     &&response != 9)
46
{switch (response)
47
{
48
    case 0:
49
        pay[p200_299] ++;
50
        break;
51
52
    case 1:
53
        pay[p300_399] ++;
54
        break;
55
    case 2:
56
        pay[p400_499] ++;
57
        break;
58
    case 3:
59
        pay[p500_599] ++;
60
        break;
61
    case 4:
62
        pay[p600_699] ++;
63-
        pay[p1000_overp ++;
63+
64
    case 5:
65
        pay[p700_799] ++;
66
        break;
67-
cin >> run;
67+
68
        pay[p800_899] ++;
69-
while(run=='y')
69+
70
    case 7:
71
        pay[p900_999] ++;
72
        break;
73
    case 8:
74
        pay[p1000_over] ++;
75
        break;
76
}}
77
cout << "Would you like to run again? (y/n)";
78
79
}//end of switch & while
80
while(response!='x');
81
}