Ben T.

asked • 05/08/19

Computer Science

Write a program that takes website names as keyboard input until the user types the word "stop" (without quotes) and counts how many of the website names are commercial website names (i.e., end with .com), then output the count.

Hint: 

(1) Declare and instantiate a scanner object called sc that can scan input from keyboard.

(2) Prompt user to enter a website and enter stop to finish the input.

(3) Enter a string from console, call it website.

(4) Declare and initialize numComSites to be zero. It will be used to check number of commercial websites entered.

(5) As long as website does not equal to string literal "stop", do the following

  begin

     if the website ends with ".com" (google usage of endsWith method of String class)

       then increase numComSites by 1.

      prompt user to enter a website and enter stop to finish the input.

      reset website by the string input

  end

   report the number of commercial web sites.

   close scanner sc.


1 Expert Answer

By:

Patrick B. answered • 05/08/19

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.