Computer Science, asked by drathbun, 7 months ago

Write a loop that inputs words until the user enters STOP. After each input, the program should number each entry and print in this format: #1: You entered _____ When STOP is entered, the total number of words entered should be printed in this format: All done. __ words entered. Sample Run Please enter the next word: cat #1: You entered cat Please enter the next word: iguana #2: You entered iguana Please enter the next word: zebra #3: You entered zebra Please enter the next word: dolphin #4: You entered dolphin Please enter the next word: STOP All done. 4 words entered.

Answers

Answered by udayagrawal49
1

Answer: The required JAVA program is :-

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

 for (int i=1 ; i<=999999 ; i++) {

  Scanner scan = new Scanner(System.in);

  System.out.print(" Please enter the next word: ");

  String w = scan.next();

  if(w.equalsIgnoreCase("STOP")){

   System.out.print(" ALL DONE."+(i-1)+" words entered.");

   break;

  }

  else{

   System.out.print("#"+i+": You entered "+w);

  }

 }

}

}

Please mark it as Brainliest.

Similar questions