#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <ctime>
#include <algorithm>
using namespace std;
// Function to generate a random name
string generateRandomName() {
const vector<string> names = {"Alice", "Bob", "Charlie", "Daisy", "Ethan", "Fiona", "George", "Hannah", "Ivy", "Jack"};
return names[rand() % names.size()];
}
// Function to generate a random toy
string generateRandomToy() {
const vector<string> toys = {"Teddy Bear", "Toy Car", "Lego Set", "Doll", "Action Figure", "Puzzle", "Board Game", "Yo-Yo"};
return toys[rand() % toys.size()];
}
// Function to generate random toy requests
vector<string> generateToyRequests(int averageToys) {
vector<string> toyList;
int numToys = max(1, rand() % (2 * averageToys)); // Random toys around the average
for (int i = 0; i < numToys; ++i) {
toyList.push_back(generateRandomToy());
}
return toyList;
}
int main() {
srand(time(0)); // Seed random number generator
// Input: Number of children and average number of toys
int numChildren, avgToys;
cout << "Enter the number of children: ";
cin >> numChildren;
cout << "Enter the average number of toys per child: ";
cin >> avgToys;
// Vector to store children and their toy requests
vector<pair<string, vector<string>>> children;
// Generate random children and toy requests
for (int i = 0; i < numChildren; ++i) {
string childName = generateRandomName();
vector<string> toyRequests = generateToyRequests(avgToys);
children.push_back({childName, toyRequests});
}
// Process goodness scores and decide toy allocation
cout << "\nResults:\n";
cout << "----------------------------------\n";
for (auto &child : children) {
string name = child.first;
vector<string> requestedToys = child.second;
// Random goodness score (1-100)
int goodnessScore = rand() % 100 + 1;
// Allocate toys based on goodness score
vector<string> grantedToys;
for (size_t i = 0; i < requestedToys.size(); ++i) {
if (goodnessScore >= 50 || (rand() % 100) < goodnessScore) { // Grant toys based on goodness
grantedToys.push_back(requestedToys[i]);
}
}
// Print results
cout << "Child: " << name << "\n";
cout << "Goodness Score: " << goodnessScore << "\n";
cout << "Requested Toys: ";
for (const string &toy : requestedToys) {
cout << toy << ", ";
}
cout << "\nGranted Toys: ";
for (const string &toy : grantedToys) {
cout << toy << ", ";
}
cout << "\n----------------------------------\n";
}
return 0;
}