0

A user inputs a website which only stops when 'stop' is typed in the input then the total of websites are totaled together.

I'm just wondering what I'm doing wrong with my code.

public class Project60
{
    public static void main (String [] args)
    {
        String website;
        int websiteCount = 0;
        String stop = "stop";

        Scanner scan = new Scanner(System.in);

        System.out.print("Please enter a website URL (e.g. www.rrc.ca) : ");
        website = scan.nextLine();

        System.out.println("(repeat above until user enters stop)");

        while( website != "stop")
        {
            System.out.print("Please enter a website URL (e.g. www.rrc.ca) : ");
            website = scan.nextLine();

            System.out.println("(repeat above until user enters stop)");

            websiteCount++;

        }

        System.out.println("There were " + websiteCount + " commercial websites entered");

    }
}
javalava
  • 23
  • 5
  • What can you do differently? Read a tutorial on Java. IMO, the language made entirely the wrong choice for representing "has the same value" versus "is the same object", but that doesn't matter, the language is what the language is. – Arfur Narf Jun 28 '23 at 23:56
  • @ArfurNarf thanks, I didn't pay attention and read the recommended material, I'm just impatient with reading sometimes and have figured it out. – javalava Jun 29 '23 at 00:22

0 Answers0