I almost got it but main has three errors. It was fine until I made the switch statement.
The errors are:
Code:
Parse Issue
Expected '(' for function-style case or type construction
Parse Issue
Expected ';' at end of declaration
Parse Issue
Expected '}'
How when I add ; where it wants and add two more } int lottoNumbers still has a warning in Main. Also what I find weird is that the } after return 0 now has to have };
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
#define SIZE 6
using namespace std;
void random_Generator(int randNum[])
{
srand((unsigned)time(NULL)); //creates a seed for rand()
for (int i=0; i<SIZE; i++) {
randNum[i] = rand() % 49; //produces random number 0-49
}
}
void compareLottoNum(int lottoNum[]) // lottoNum[] gets the user picked lotto numbers
{
int numbers[SIZE]; // will be used to store the random numbers in this function
int count = 0;
random_Generator(numbers); /*random numbers are called and below compared against the users numbers*/
for (int i=0; i<SIZE; i++){
if (lottoNum[i]==numbers[0]||numbers[1]||numbers[3]||numbers[4]||numbers[5]) {
count++;
}
if (count<=1) {
cout<<"You lost, maybe nexted time"<<endl;
}
switch (count) {
case 2:
cout<<"You got two numbers right, you won 5 Euro"<<endl;
break;
case 3:
cout<<"You got three numbers right you won 20 Euro"<<endl;
break;
case 4:
cout<<"You got four right, you won 2,000 Euro"<<endl;
case 5:
cout<<"You have won 100,000 Euro"<<endl;
case 6:
cout<<"JACKPOT!!\n You won 1,000,000,000 Euro!!!"<<endl;
break;
default:
break;
}
int main(int argc, const char * argv[])
{
int lottoNumbers[SIZE];
cout<<"Enter 6 lotto numbers"<<endl;
for (int i=0; i<6; i++) {
cin>>lottoNumbers[i];
}
compareLottoNum(lottoNumbers);
return 0;
}