On line 6 you declare 4 variables, c, sw, random and n. These all have the same type, int. int is one of the primitive types in Java which means it does not have any methods or fields you can call using the dot operator.
You are calling n.nextInt(47);. There are two methods called nextInt that take a single int value - one in java.util.Random and one in java.util.Scanner. Since in the latter the int is the radix I assume you actually want the former. For that you would need an instance of java.util.Random.
I think that line 6 is actually a mistake; either you copied it incorrectly or your teacher made a mistake. I think it should be this:
And can you please UseCodeTags next time? Make sure to preserve the indentation as well.
Your teacher couldn't get a job doing what they're teaching. That's awful.
no, that is common. we used to joke about it, but it isn't really funny. if the economy and especially education weren't in such a bind now i could even get a job as a teacher. they don't even require degrees anymore
Ken Blair wrote:Your teacher couldn't get a job doing what they're teaching. That's awful.
There's a whole industry of certification exams which appears (to me) to require people to look at horribly bad code and figure out what it does. On the one hand, figuring out what horribly bad code does is a useful skill. But on the other hand I have this sinking feeling that the people who take those exams might be taking the exam questions as examples to be imitated.