Help with writing code

pandabear (2)
I have my code complete pretty much but the last part is that I need to have a counter for how many candidates were accepted into the program and the percentage.

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <iostream>
#include <iomanip>
using namespace std;



 int main()

{

		// INPUT: The users input information.

	 	char gender;
	 	bool heightOk;
	 	bool weightOk;
	 	int height;
	 	int weight;





		// PROCESSING: Entering the users information for qualification.

		cout << "Please enter the candidates information (Enter 'x' to exit) " << endl;
		do
		{
			cout << setw(10) << "Gender: ";
			cin.get(gender);
			cin.ignore(1000, '\n');

			if (gender != 'x' && gender != 'X' && gender != 'F' && gender != 'f' && gender != 'm' && gender != 'M') {
				cout << "***** Invalid gender; please enter M or F *****" << endl;
			}


		}while(gender != 'x' && gender != 'X' && gender != 'F' && gender != 'f' && gender != 'm' && gender != 'M');




		while(gender != 'x' || gender != 'X')
		{

			if (gender == 'f' || gender == 'F') {

			do
			{
				cout << setw(10) << "height: ";
				cin >> height;
				heightOk = (height >=62 && height <= 75);


			}while(height >=25 && height <= 110);
				cout << "***** Invalid height; please enter a height in inches between 24 and 110. *****" << endl;

			do
			{
				cout << setw(10) << "weight: ";
				cin >> weight;
				weightOk = (weight >= 110 && weight <= 185);

			}while(weight >= 50 && weight <= 1400);
				cout << "***** Invalid weight; please enter a weight in lbs between 50 and 1400. *****" << endl;

			}
			else if(gender == 'm' || gender == 'M')
			{

			do
			{

				cout << setw(10) << "height: ";
				cin >> height;
				heightOk = (height >=65 && height <= 80);

			}while(height >=25 && height <= 110);
			 cout << "***** Invalid height; please enter a height in inches between 24 and 110. *****" << endl;

			do
			{
				cout << setw(10) << "weight: ";
				cin >> weight;
				weightOk = (weight >= 130 && weight <= 250);
				cin.ignore(1000, '\n');

			}while(weight >= 50 && weight <= 1400);
				cout << "***** Invalid weight; please enter a weight in lbs between 50 and 1400. *****" << endl;
			}


			if (heightOk == 1 && weightOk == 1) {

				cout << "\n\nThis candidate has been ACCEPTED!" << endl << endl;}

			counter = counter +1+1

			else if(heightOk == 0 && weightOk == 1) {


				cout << " \nThis candidate has been rejected based on the HEIGHT requirement" << endl;}

			else if(heightOk == 1 && weightOk == 0) {

				cout << "\nThis candidate has been rejected based on the Weight requirement" << endl;}

			else if (heightOk == 0 && weightOk == 0) {

				cout << "\nThis candidate has been rejected based on the Weight and HEIGHT requirement" << endl;}


			cout << "\n\n\nPlease enter the candidates information (Enter 'x' to exit) " << endl;

			do
			{

				cout << setw(10) << "Gender: ";
				cin.get(gender);
				cin.ignore(1000, '\n');

				if (gender != 'x' && gender != 'X' && gender != 'F' && gender != 'f' && gender != 'm' && gender != 'M') {
					cout << "invalid entry" << endl;
				}


			}while(gender != 'x' && gender != 'X' && gender != 'F' && gender != 'f' && gender != 'm' && gender != 'M');



		}



 	 	// OUTPUT: Details of what is being output.

		return 0;

}


Last edited on
deanfvjr (33)
And your question is..... Are we supposed to write you a counter or something........


I hope thats not what this post was about because this is not FREECODEWRITERS.org.
Last edited on
Registered users can post here. Sign in or register to post.