int a; 

double x; 

a = read.nextInt()

x = a; 

x = 0.5 * ( x + a / x) 
x = 0.5 * ( x + a / x) 
x = 0.5 * ( x + a / x) 
x = 0.5 * ( x + a / x) 

// n = n + 1;

--

while (COND) {
  BODY; 
}

import java.util.Scanner; 

public class Exercise {
  public static void main(String[] args) {
     Scanner read = new Scanner(System.in);  
     System.out.print("Number: "); 
     double a = read.nextDouble(); 
     double x = a; 
     while (Math.abs(x * x - a) > 0.00001) {
       x = 0.5 * (x + a/x);  
       System.out.println( x ); 
     }
  }
}

for ( INIT ; COND ; STEP ) {
  BODY;
}

Every for can be converted to a while like this:

INIT; 
while (COND) {
  BODY;
  STEP; 
}

import java.util.Scanner; 

public class Exercise {
  public static void main(String[] args) {
     Scanner read = new Scanner(System.in);  
     System.out.print("Sentence: "); 
     String sentence = read.nextLine(); 
     System.out.println( sentence ); 
     for (int i = 0; i < sentence.length(); i = i + 1) {
       System.out.println( i + ". " + sentence.charAt(i) );  
     }
  }
}

Now write this program: 

-bash-3.2$ java Profiler
Please enter a word or a sentence to profile: banana
b shows up 1 times in the given sentence.
a shows up 3 times in the given sentence.
n shows up 2 times in the given sentence.
-bash-3.2$ java Profiler
Please enter a word or a sentence to profile: watermelon and onions
w shows up 1 times in the given sentence.
a shows up 2 times in the given sentence.
t shows up 1 times in the given sentence.
e shows up 2 times in the given sentence.
r shows up 1 times in the given sentence.
m shows up 1 times in the given sentence.
l shows up 1 times in the given sentence.
o shows up 3 times in the given sentence.
n shows up 4 times in the given sentence.
  shows up 2 times in the given sentence.
d shows up 1 times in the given sentence.
i shows up 1 times in the given sentence.
s shows up 1 times in the given sentence.
-bash-3.2$ java Profiler
Please enter a word or a sentence to profile:                 
  shows up 17 times in the given sentence.
-bash-3.2$ java Profiler
Please enter a word or a sentence to profile:
-bash-3.2$ java Profiler
Please enter a word or a sentence to profile:            .
  shows up 11 times in the given sentence.
. shows up 1 times in the given sentence.
-bash-3.2$ 

https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#contains-java.lang.CharSequence-

import java.util.Scanner; 

public class Exercise {
  public static void main(String[] args) {
     String memory = ""; 
     Scanner read = new Scanner(System.in);  
     System.out.print("Sentence: "); 
     String sentence = read.nextLine(); 
     System.out.println( sentence ); 
     for (int i = 0; i < sentence.length(); i = i + 1) {
       if (memory.contains(sentence.substring(i, i+1))) {
         
       } else { 
         memory = memory + sentence.charAt(i);
         System.out.println( i + ". " + sentence.charAt(i) + " occurs " + 
                             Exercise.occurs(sentence.charAt(i), sentence) + 
                             " times.");  
       }
     }
  }
  public static int occurs(char c, String s) {
    int times = 0; 
    for (int i = 0; i < s.length(); i = i + 1) {
      if (s.charAt(i) == c) {
        times += 1;  
      }
    }
    return times; 
  }
}

--

How about something like this: 

-bash-3.2$ java Four 16
                *
              *
            *
          *
        *
      *         *
    *           *
  *             *
* * * * * * * * * * *
                *
                *
                *
                *
                *
                *
                *
-bash-3.2$ java Four 21
                    *
                  *
                *
              *
            *
          *
        *
      *             *
    *               *
  *                 *
* * * * * * * * * * * * * * *
                    *
                    *
                    *
                    *
                    *
                    *
                    *
                    *
                    *
                    *
-bash-3.2$ java Four 9
        *
      *
    *
  *     *
* * * * * * *
        *
        *
        *
        *
-bash-3.2$

--

import java.util.Scanner; 

public class Exercise {
  public static void main(String[] args) {
    Scanner read = new Scanner(System.in); 
    System.out.print("What size: "); 
    int size = read.nextInt(); 
    for (int row = 0; row < size; row += 1) {
      for (int col = 0; col < size; col += 1) {
        if (col == 0 || col == size - 1 || col == row) {
          System.out.print("* ");  
        } else {
          System.out.print("  ");  
        }
      }
      System.out.println(); 
    }
  }
}

Here are some other patterns to choose from: 

Here are some examples to choose from:
-bash-3.2$ java Kyu 15
              *
            *   *
          *       *
        *           *
      *               *
    *                   *
  *                       *
*                           *
  *             *           *
    *             *       *
      *             *   *
        *             *
          *         *   *
            *     *       *
              * *           *
-bash-3.2$ java Kiu 23
                      *
                    *   *
                  *       *
                *           *
              *               *
            *                   *
          *                       *
        *                           *
      *                               *
    *                                   *
  *                                       *
*                                           *
  *                     *                   *
    *                     *               *
      *                     *           *
        *                     *       *
          *                     *   *
            *                     *
              *                 *   *
                *             *       *
                  *         *           *
                    *     *               *
                      * *                   *
-bash-3.2$
The pattern above resembles the letter Q, here's uppercase R:
-bash-3.2$ javac R.java
-bash-3.2$ java R 12
* * * * * * * * * * * *
*                     *
*                     *
*                     *
*                     *
*                     *
* * * * * * * * * * * *
*             *
*               *
*                 *
*                   *
*                     *
-bash-3.2$ java R 23
* * * * * * * * * * * * * * * * * * * * * * *
*                                           *
*                                           *
*                                           *
*                                           *
*                                           *
*                                           *
*                                           *
*                                           *
*                                           *
*                                           *
* * * * * * * * * * * * * * * * * * * * * * *
*                       *
*                         *
*                           *
*                             *
*                               *
*                                 *
*                                   *
*                                     *
*                                       *
*                                         *
*                                           *
-bash-3.2$ java R 8
* * * * * * * *
*             *
*             *
*             *
* * * * * * * *
*         *
*           *
*             *
-bash-3.2$
Here's how I draw uppercase Z as a scalable pattern:
-bash-3.2$ java Z 12
* * * * * * * * * * * *
                    *
                  *
                *
              *
            *
      * * * * * * *
        *
      *
    *
  *
* * * * * * * * * * * *
-bash-3.2$ java Z 23
* * * * * * * * * * * * * * * * * * * * * * *
                                          *
                                        *
                                      *
                                    *
                                  *
                                *
                              *
                            *
                          *
                        *
          * * * * * * * * * * * * *
                    *
                  *
                *
              *
            *
          *
        *
      *
    *
  *
* * * * * * * * * * * * * * * * * * * * * * *
-bash-3.2$ java Z 9
* * * * * * * * *
              *
            *
          *
    * * * * *
      *
    *
  *
* * * * * * * * *
-bash-3.2$

--

Welcome to DrJava.  Working directory is C:\Users\dgerman.ADS.000\Desktop
> int a
> a = (int) (Math.random() * 6) + 1
5
> a = (int) (Math.random() * 6) + 1
2
> a = (int) (Math.random() * 6) + 1
4


And now in anticipation of the lab today:

Welcome to DrJava.  Working directory is C:\Users\dgerman.ADS.000\Desktop
> int[] a
> int b[]
> a = new int[3]
{ 0, 0, 0 }
> a
{ 0, 0, 0 }
> b = new int[8]
{ 0, 0, 0, 0, 0, 0, 0, 0 }
> b
{ 0, 0, 0, 0, 0, 0, 0, 0 }
> a
{ 0, 0, 0 }
> a[0] = 3
3
> a
{ 3, 0, 0 }
> a[1] = -2
-2
> a
{ 3, -2, 0 }
> int n = 10
> int[] c = new int[n]
> c
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }


--