Homework #09 (Due: Fri 06 Feb)

\begin{purpose}
This assignment makes use of a common form of {\tt while} loop i...
...nd to watch the values of
variables as the each step is completed.
\end{purpose}

As you may know from having watched episodes of ``The Simpsons'', Bart often gets into trouble at school and is required to write sentences over and over again on the chalk board. Your assignment is to construct an program that will write a message over and over again for Bart (given a sentence and the number of times the sentence should be written).

Your program should allow the user to enter a sentence and how many times the sentence should be displayed. The output, of course, will be the sentence however many times the user requested it. The statements below illustrate how to declare, read, and display a sentence:

  public static void main(String [] args)
  {
    Scanner scan= new Scanner(System.in);
    String msg;
    System.out.print("Enter message: ");
    msg= scan.nextLine();
    System.out.println(msg);
  }

NOTE: For this program, have the user enter the sentence before they enter the number of times they want to display the sentence. We'll investigate why later.

tsergeant@hsutx.edu

Quick Links