// // ... // P. 48 Method // Goal: read from keyboard, out its cubic. Use loops // import java.util.Scanner; class P48 { public static void main(String[] args) { Scanner input = new Scanner(System.in); double aVal; double myResult; System.out.print("Input a pos. (neg. to quit): "); aVal = input.nextDouble(); while(aVal>0) { myResult = Cubic(aVal); System.out.println("Square of " + aVal + " is " + myResult); System.out.print("Input a pos. (neg. to quit): "); aVal = input.nextDouble(); } System.out.println("\n\n\nDone.\n\n"); } private static double Cubic(double s) { return s*s*s; } }