Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Computer Science

CHRIS AJAYI-OBE
CHRIS AJAYI-OBE
1,836 Points

Can anyone spot the issue with my code?

Hi guys, I'm working through the Feeling Loopy with Java lesson and am following along in a separate workspace .I'm on the final video ,Branching Statements and have copied the code exactly as I see .Ive gone through the errors but can't seem to spot them.

I included my code below.Many Thanks. import java.io.Console;

public class Prizes {

public static void main(String[] args) { Console console = System.console(); String[] rsvps = Rsvps.shuffled(); int prizesGivenAway = 0; int drawingNumber = 0; }

while (prizesGivenAway < 5) {
  String winner = rsvps[drawingNumber];
  drawingNumber++;
  console.printf("Is %s present?  ", winner);
  string isHere = console.readLine();
  if (isHere.equalsIgnoreCase("no")) {
    continue;
  }

  String size = console.readLine("What is your shirt size?  ");
  prizesGivenAway++;
}

}

import java.io.Console;


public class Prizes {

    public static int main(String[] args) { 
        Console console = System.console(); 
        String[] rsvps = Rsvps.shuffle(); 
        int prizesGivenAway = 0; 
        int drawingNumber = 0; 

        while ( prizesGivenAway < 5 ) {
            String winner = rsvps[drawingNumber];
            drawingNumber++;
            console.printf("Is %s present?  ", winner);
            String isHere = console.readLine();
            if (isHere.equalsIgnoreCase("no")) {
                continue;
            }

            String size = console.readLine("What is your shirt size?  ");
            prizesGivenAway++;
        }
    }   
}

You just need include you loop in side you main function, and capitalize your "isHere" string type like "String". after that you should be good. Good luck :)

1 Answer

CHRIS AJAYI-OBE
CHRIS AJAYI-OBE
1,836 Points

Thanks jhon White.

Appreciate the help.

you are welcome :)