2.18 (Printing
a table) Write a program that displays the following table:
A b
pow(a, b)
1 2 1
2 3 8
3 4 81
4 5 1024
5 6 15625
Code : File name-PrintingTable.java
import java.util.*;
import javax.swing.*;
public class PrintingTable {
public static void
main (String arg[]){
System.out.println("a
b pow(a,b)");
System.out.println("1
2 1");
System.out.println("2 3
8");
System.out.println("3
4 81");
System.out.println("4
5 1024");
System.out.println("5
6 15625");
}
}
2.19 (Random
character) Write a program that displays a random uppercase letter using
the System.CurrentTimeMillis() method.
Code :
File name-RandomCharacter.java
import java.util.*;
import javax.swing.*;
public class RandomCharacter {
public static void main (String arg[]){
long totalMilliseconds =
System.currentTimeMillis();
long v = totalMilliseconds%25;
System.out.print ((char)(65+v));
}
}