Okay so I have to have write a program that takes website names until you type stop.
After that it should count how many websites were entered.

package website;

/**
 *
 * @author 
 */
import java.*;
import java.util.Scanner;
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int com = 0;
     

      //It'll catch the website name here
      System.out.println("Please enter a website name: ");
      String url = scan.next();

      int dotCom = url.indexOf(".com");
      int stop = url.indexOf("stop");
      
      while(!url.equals(stop))
      {
         if ( dotCom > 0)
         com = com + 1;
         System.out.println(com);
        
         if (stop > 0)
         {
             System.out.println(com);
             break;
          }
          }
           
        
           
    }

}

Right now it just adds numbers and doesn't stop after you enter in a domain name.

1. You can use a do...while loop, rather than a while loop so you check the condition at the end of the loop instead of at the beginning.
2. You should put everything from the prompt to enter the website on inside the loop.
3. Think about what the condition should be for exiting the loop.
4. After the loop ends, that's when you should print out the number of websites you read in.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.