/* Hellos.java by Craig Persiko
CS 111A Solution to in-class exercise:
Write a program that outputs "hello" to the user as many times as
specified. So ask the user how many times to repeat the greeting,
then use a loop to output it that many times. For an extra
challenge, alternate between captial and lower-case words, such as:
How many times should I say hello? 5
hello HELLO hello HELLO hello
*/
import java.util.Scanner;
public class Hellos
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int numHellos;
System.out.print("How many hellos? ");
numHellos = s.nextInt();
while(numHellos > 0)
{
numHellos--;
if(numHellos % 2 == 0)
System.out.print("hello ");
else
System.out.print("HELLO ");
}
}
}
syntax highlighted by Code2HTML, v. 0.9