int draw, even(0), seven(0), one_two_three(0); // Declare Variables
double percent_of_even, percent_of_seven, percent_123;
int maxpos = 1;
int ct = 1;
double status =1;
while(status==1)
{
// Input From User
cout << "How many lottery drawings will be simulated? =>";
cin >> draw; //number of lottery drawing
cout << ' ' << endl;
if(draw<1 || draw>10)
{
status=1;
cout<<"Number of lottery drawing must be greater than 0!\n";
}
else
{
status=0;
}
}
// Randomize numbers
srand(draw);
// Continue Drawing requested Amount
while (ct <= draw)
{
cout <<"Roll#"<<ct<<"\n";
for (int k = 1; k <= 5; k++)
{
// Output to Screen
cout << ' ' << endl;
cout << "Percentage of all even " << percent_of_even << "%" << endl;
cout << "Percentage of all sevens " << percent_of_seven << "%" << endl;
cout << "Percentage of all 1-2-3-4-5 order " << percent_123 << "%" << endl;
cout << ' ' << endl;
}
int main()
{
int loop=0;
do
{
ball_drawings();
cout<<"Another round for the lottery? Type 1 for yes, any other number for no";
cin>>loop;
}while(loop==1);
return(0);
}
this is the code I did
and this is the output I should get
Enter number of lottery drawings =>-4
Number of lottery drawings must be greater than 0!
Please re-enter number of lottery drawings =>5
Roll #1
5 9 6 4 10
Roll #2
10 9 7 3 2
Roll #3
6 5 3 1 4
Roll #4
5 6 2 4 3
Roll #5
10 1 9 8 4
Percentages of all even = 0%
Percentages of sevens = 20%
Percentages of all 1-2-3-4-5 order = 0%
Another round for the lottery? Type 1 for yes, any other number for no: 1
Enter number of lottery drawings =>3
The numbers that you are displaying, and the numbers that you are calculating stats for are different. Also, the formula for calculating your stats are mostly wrong.
Don't generate new numbers to check if they're even.
Don't generate new numbers to check if they're sevens.
Don't generate new numbers to check if they're in ascending order.
Rather, record the numbers when you generate them and use the recorded numbers to generate your statistics.