Project Help

I need a way to compare a number to the amount of times a string was entered. In my project i need to make sure that when a category for a bunch is selected like 'P' for pretty_category or 's' for so_category, it is not greater than the number the user said was already in that specific category in the beginning of the program.

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
  #include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;

int num_check(int num);
int num_check2(int num2);



int main() {



	int  w = 0, x = 0, y = 0, z = 0;
	int pretty_category, so_category, ugly_category;
	int category;
	string type1,type2,type3,type4,type5;
	cout << "How many flowers are in the Pretty Category?" << endl;
	pretty_category = num_check(x);
	cout << "How many flowers are in the So-So Category?" << endl;
	so_category = num_check(y);
	cout << "How many flowers are in the Ugly Category?" << endl;
	ugly_category = num_check(z);

	cout << "How many categories are in this basket" << endl;
	category = num_check2(w);

	if (category == 1) {
		cout << "What category for the 1st bunch: " << endl;
		cin >> type1;

	}

		else if (category == 2) {
		cout << "What category for the 1st bunch: " << endl;
		cin >> type1;
		cout << "What category for the 2nd bunch: " << endl;
		cin >> type2;
	}
	else if (category == 3) {
		cout << "What category for the 1st bunch: " << endl;
		cin >> type1;
		cout << "What category for the 2nd bunch: " << endl;
		cin >> type2;
		cout << "What category for the 1st bunch: " << endl;
		cin >> type3;
		
	}
	else if (category == 4) {
		cout << "What category for the 1st bunch: " << endl;
		cin >> type1;
		cout << "What category for the 2nd bunch: " << endl;
		cin >> type2;
		cout << "What category for the 1st bunch: " << endl;
		cin >> type3;
		cout << "What category for the 1st bunch: " << endl;
		cin >> type4;
	}
	else if (category == 5){
		cout << "What category for the 1st bunch: " << endl;
		cin >> type1;
		cout << "What category for the 2nd bunch: " << endl;
		cin >> type2;
		cout << "What category for the 1st bunch: " << endl;
		cin >> type3;
		cout << "What category for the 1st bunch: " << endl;
		cin >> type4;
		cout << "What category for the 1st bunch: " << endl;
		cin >> type5;
	}

	
	





	system("pause");
	return 0;
}



int num_check(int num) {

	cin >> num;
	while (num < 0) {
		cout << "Error try again" << endl;
		cin >> num;
	}
	return num;
}

int num_check2(int num2) {
	cin >> num2;

	while (num2 < 1 || num2>5) {
		cout << "Error try again" << endl;
		cin >> num2;
	}


	return num2;
}

Last edited on
Topic archived. No new replies allowed.