New to Functions

Below is my code. I have made this program and now am trying to use functions in it and I CAN'T use global variables. Can I get some pointers on what to do? Am I using my functions correctly? I am new to this...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std; 

void myFunction(double randomizer, double selection)
{
   for(int i=1; i<=12; i++) //12 iterations starting from 1
   {
        randomizer = rand() % 2;
        if (randomizer == 0)
        {
           selection += ( selection == 8  ) ?  -0.5 : 0.5;
     	} 
        else
        {
           selection += ( selection == 0  ) ?  0.5 : -0.5; 	
        }
        cout << selection << endl; //print out the 12 iterations
   }
}
int myOtherFunction(int selection, int user_winnings)
{
if (selection == 0){
	user_winnings = 100;
}
if (selection == 1){
	user_winnings = 500;
}
if (selection == 2){
	user_winnings = 1000;
}
if (selection == 3){
	user_winnings = 0;
}
if (selection == 4){
	user_winnings = 10000;
}
if (selection == 5){
	user_winnings = 0;
}
if (selection == 6){
	user_winnings = 1000;
}
if (selection == 7){
	user_winnings = 500;
}
if (selection == 8){
	user_winnings = 100;
	return user_winnings;
}
}
int main()
{
//set variables
int choice;
double selection;
int where_drop = 0;
double user_winnings;
int randomizer;
int multiple_chips;
double selection_two;
int randomizer_two;
double user_winnings_two;
double average_winnings;
bool gameOn = true;

//make menu screen
while (gameOn != false){
cout << "***GAME MENU***\n";
cout << " 1 - Drop one chip into one slot.\n";
cout << " 2 - Drop multiple chips into one slot.\n";
cout << " 3 - Drop Multiple chips into every slot.\n";
cout << " 4 - Exit.\n";
cin >> choice;

//menu choices below in switch
switch (choice)
{
case 1:
	
	cout << "\n Which Slot would you like to Drop a chip in(Please enter a slot #0-8)?"<<"\n";
	cin >> selection;

if((selection < 0) || (selection > 8))//if a negative number or greater than 8 go back to menu
{
	break;
}

srand(time(0));  //seed the random number

void myFunction();

//find winnings
int myOtherFunction();
//print out winnings
	cout<<"You've won $" << user_winnings << "!" << endl;

break;
case 2: //second option

cout << "\n How many chips would you like to play?"<<"\n";
cin >> multiple_chips;

if(multiple_chips < 0)//don't allow negative numbers
{
	break;
}

cout << "\n Which Slots would you like to Drop the chip(s) into(Please enter a slot #0-8)?"<<"\n";
cin >> selection;

if((selection < 0) || (selection > 8))//only allow 0-8 as option or return to menu
{
	break;
}

void myFunction();

//find winnings. 
int myOtherFunction();

//final calculations
average_winnings = user_winnings / multiple_chips;

	cout<<"You've won  a total of $" << user_winnings << "!" << endl;
	cout<<"You averaged winnings of $" << average_winnings << " a chip." << endl;

break;
case 3:
cout << "New stuff.\n";//working on finishing
break;
case 4://quit program
cout << "End of Program.\n";
gameOn = false;
break;
default:
cout << "Not a Valid Choice. \n";
cout << "Choose again.\n";
break;
cin >> choice;

}

}
return 0;
}
Topic archived. No new replies allowed.