- Create a new class named GeneratingTables.
- Create a method named generateTable that takes no parameters.
public static void generateTable(){
int i = 1;
while (i < 10){
double x = (double)i;
System.out.println(x + " " + Math.log(x));
i = i + 1;
}
}
- Add a main method and code in main that calls generateTable.
public static void main(String[] args){
generateTable();
}
The completed class should appear as follows.
public class GeneratingTables {
public static void generateTable(){
int i = 1;
while (i < 10){
double x = (double)i;
System.out.println(x + " " + Math.log(x));
i = i + 1;
}
}
public static void main(String[] args){
generateTable();
}
}
- Compile and run the program.
$ javac GeneratingTables.java $ java GeneratingTables 1.0 0.0 2.0 0.6931471805599453 3.0 1.0986122886681098 4.0 1.3862943611198906 5.0 1.6094379124341003 6.0 1.791759469228055 7.0 1.9459101490553132 8.0 2.0794415416798357 9.0 2.1972245773362196


