/* * Square2.java * * Recebe um argumento numerico e exibe em uma linha na tela o quadrado * e a raiz quadrada desde o numero 1 ate o argumento dado. * * Ilustra uso das rotinas de formatacao em java.text * */ import java.text.*; class Square2 { public static void main (String[] args) { DecimalFormat form = new DecimalFormat("#.0###"); if ( args.length > 0 ) { int valorMaximo = Integer.parseInt(args[0]); for (int corrente = 1; corrente <= valorMaximo; corrente++) { System.out.println(corrente + "\t" + corrente*corrente + "\t" + form.format(Math.sqrt(corrente))); } // end of for (int = 0; < ; ++) } // end of if () else { System.err.println("Square requer um argumento numerico"); } // end of if ()else } // end of main () }