delete

closed account (i8bjz8AR)
delete
Last edited on
using namespace std;

should go after #includes
line 64. Separate your comparisons... () && () && ()
line 138 You don't have a function named coinResult.
Line 139 Something is not defined
Lines 142 - 145 is not right.

line 64: coinFlip is a number, and you are comparing it to a string.

How can a number ever be equal to "H" ?
closed account (i8bjz8AR)
delete
Last edited on
Line 64

coinflip is an int, not a char...

It can == 1 2,3... not A b c
1
2
3
4
5
while (coinFlip != "H" && coinFlip != "h" && coinFlip != "T" && coinFlip != "t")
    {
        cout << "Please choose either 1 or 0, or 'H' or 'T', without single quotes!\n\n" << endl;
        cin >> coinFlip;
    }


Since coinFlip is defined as an integer, how can it's value ever be "H"?

Further, if a user types in "H", how can possibly that value be assigned to coinFlip, which must be an integer?

closed account (i8bjz8AR)
So now I have "char coinFlip;", but i'm still getting that error, what do i need to do?
Last edited on
char is OK.

Now:
a) "H" is not a char, it is a string (more or less). 'H' is a char.

b)
coinFlip = rand()%2;

What is this supposed to do now that coinFlip is a char? You can't assign 0 to a char. '0' and '1' are chars, 0 and 1 are numbers.
closed account (i8bjz8AR)
so a random number 0 || 1 is supposed to be assigned, but since coinFlip is a char, it needs an "int" data type, i'm just so lost on how to fix this because i'm a beginner.
if ( rand()%2==0) coinFlip = '0';
else coinFlip = '1';
Last edited on
closed account (i8bjz8AR)
delete
Last edited on
Here are some fixes:

a) Why did you add the curly brackets?
1
2
3
    if ( rand()%2==0) 
        coinFlip = '0';
    else coinFlip = '1';


b)
while (coinFlip != 'H' && coinFlip != 'h' && coinFlip != 'T' && coinFlip != 't')
closed account (i8bjz8AR)
delete
Last edited on
You are still having an extra curly brace at line 35.

How does that continue to happen? Is your computer inserting extra curly braces at random?
closed account (i8bjz8AR)
I honestly have no idea.. Went to 48 to 5! Thank you! Now are those other errors a big problem... I tried renaming those and still get that function error. also the "'const char*' ", does this have to do with "coinToss" being a int instead of a char? (149-152)
Last edited on
Well, yes, you shouldn't assign integers to chars, although the compiler will probably allow it.

But, the problem in line 142 is that coin_toss is not a function, and you are using a function call operator there. So that has to be fixed, but I can't figure out what did you have in mind there.
closed account (i8bjz8AR)
I was just trying to give a value to coinToss to display "You have chosen heads" or "you have chosen tails"
To give a value to coinToss, you need to use an assignment operator. For example:

coinToss = 0;

or:

coinToss = rand()%2;
Last edited on
Topic archived. No new replies allowed.