necessary code to Program 5 to find the minimum and maximum donation

icon
Related questions
Question

Add the necessary code to Program 5 to find the minimum and maximum
donation

Program 5 Using queue to categorize data
1
2
* The program to simulate receiving donations and categorize *
3 * into five groups base on the value using queues
*
لیا در
4 *******
5 #include "queue.cpp"
6 #include <cstdlib>
7 #include <ctime>
8
9 void print (Queue <int>); // Declaration of print function
10
11 int main()
1*/
Transcribed Image Text:Program 5 Using queue to categorize data 1 2 * The program to simulate receiving donations and categorize * 3 * into five groups base on the value using queues * لیا در 4 ******* 5 #include "queue.cpp" 6 #include <cstdlib> 7 #include <ctime> 8 9 void print (Queue <int>); // Declaration of print function 10 11 int main() 1*/
Program 5 Using queue to categorize data (continued)
12 {
13
14
15
16
17
18
53
54
55
56
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
// Instantiation of queues and declaration of variables
Queue <int> queue1, queue2, queue3, queue4, queue5;
int num;
int donation;
// Simulation of donations arrival and pushing into queues
srand (time (0));
for (int i = 0; i < 50; i++)
{
num rand ():
donation = num % (50 - 0 + 0) + 0;
switch (donation / 10)
{
57
58
59}
}
case 0: queue1.push (donation);
break;
case 1: queue2.push (donation);
break;
case 2: queue3.push (donation);
break;
case 3: queue4.push (donation);
break;
case 4: queue5.push (donation);
break;
}
// Print the queue to see different categories
cout << "Donations between 00 and 09: ";
print (queue 1);
cout << "Donations between 10 and 19: ";
print (queue2);
cout << "Donations between 20 and 29: ";
print (queue3);
cout << "Donations between 30 and 39: ";
print (queue4);
cout << "Donations between 40 and 49: ";
print (queue5);
return 0:
49 }
50 // Definition of the print function
51 void print (Queue <int> queue)
52 {
Program 5 Using queue to categorize data (continued)
while (!queue.empty())
{
cout << queue.front () << " ";
queue.pop();
}
cout << endl;
Transcribed Image Text:Program 5 Using queue to categorize data (continued) 12 { 13 14 15 16 17 18 53 54 55 56 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 // Instantiation of queues and declaration of variables Queue <int> queue1, queue2, queue3, queue4, queue5; int num; int donation; // Simulation of donations arrival and pushing into queues srand (time (0)); for (int i = 0; i < 50; i++) { num rand (): donation = num % (50 - 0 + 0) + 0; switch (donation / 10) { 57 58 59} } case 0: queue1.push (donation); break; case 1: queue2.push (donation); break; case 2: queue3.push (donation); break; case 3: queue4.push (donation); break; case 4: queue5.push (donation); break; } // Print the queue to see different categories cout << "Donations between 00 and 09: "; print (queue 1); cout << "Donations between 10 and 19: "; print (queue2); cout << "Donations between 20 and 29: "; print (queue3); cout << "Donations between 30 and 39: "; print (queue4); cout << "Donations between 40 and 49: "; print (queue5); return 0: 49 } 50 // Definition of the print function 51 void print (Queue <int> queue) 52 { Program 5 Using queue to categorize data (continued) while (!queue.empty()) { cout << queue.front () << " "; queue.pop(); } cout << endl;
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer