
import static java.lang.System.*;

public class HelpWhileLoops 
{
  public static void main(String[] args) 
  {
       
  out.println("The while loop");
  out.println();
  out.println();
    
  
  System.out.println("HeLlo Caps");
  String s = "HeLlo";
  int i = 0; // init index i first!
  while (i < s.length()) // while (boolean expression)
  {
    char ch = s.charAt(i); // get the ith character
    System.out.print("i=" + i + "  ");
    if (ch >= 'A' && ch <= 'Z')
    {
       System.out.print("ch=" + ch + "  ");
    }
    i++;  // add 1 to index i
  }
  out.println();
  out.println();
  

  
  System.out.println("Hello in Reverse");
  s = "Hello";
  i = s.length()-1; // start at last character position
  
  // loop as long as i is greater than or equal to 0
  while (i >= 0) 
  {
    char ch = s.charAt(i); // get the ith char
    System.out.print("i=" + i + "  ch=" + ch + "  ");
    i--;
  }
  out.println();
  out.println();
  

  System.out.println("Hello World by 2");
  s = "Hello World";
  i = 0; // init i first
  // loop as long as i is less than the length of s
  while (i < s.length())
  {
    char ch = s.charAt(i); // get the ith char
    System.out.print("i=" + i + "  ch=" + ch + "  ");
    i += 2;
  }
  out.println();
  out.println();

  
  System.out.println("Numbers 1");
  int number = 28;
  int d = 1;
  // loop through all d's from 1 to number
  while (d <= number)
  {
    // check and see if d divides evenly 
    // into number
    if (number % d == 0)
    {
       System.out.print(d + " ");
    }
    d++;  // next divisor please
  }
  out.println();
  out.println();  
 
  /*
  System.out.println("Numbers 2");
  number = 19;
  int count = 0;
  d = 1;
  while (d <= number)
  {
    if (number % d == ?)
       count++;
    ???  // next d please
  }
  if (count == ?)
      out.println(number + " is a prime example!"); 
  out.println();
  out.println();  
  
*/
  
  out.println();
  out.println();
  } // end of main method
  
} // end of class


