Display the total amount per section code and the overall total
4. At the end of each event five (5) lucky customers are randomly chosen from the name
array to win daily prizes. Call a function to accomplish this.
5. Display the names of the five lucky winners.(15
#include <iostream>
#include <string>
class Customer
{
std::string name = "a";
bool win = false;
public:
void set_win()
{
win = true;
}
const bool& get_win()
{
return win;
}
const std::string & get_name()
{
return name;
}
};
int main()
{
Customer customers[100] = {};
int event_number = 0;
std::cout << "Enter the event number: ";
std::cin >> event_number;
for(int i = 1; i <= event_number; i++)
{
for(int j = 0; j != 5; ++j)
{
int i = std::rand() % 100;
if(!customers[i].get_win())
{
customers[i].set_win();
std::cout<<"The winner is: "<<customers[i].get_name()<<i<<std::endl;
}
}
}
return 0;
}
Comments
Leave a comment