/** * good resource: http://docs.oracle.com/javase/tutorial/essential/io/scanning.html * @author gracielaelia * Problem: Both hasNext and next methods may block waiting for further input. * hasNext() doesn't return false ever!!!! next() blocks until something is input! * As you're reading from stdin, that'll either be when you send an EOF character (usually ^d on Unix), * or at the end of the file if you use < style redirection. * You cannot easily send and EOF character using the keyboard" * -- usually Ctrl+D on Linux/Unix/Mac * or Ctrl+Z on Windows does it */ import java.util.Scanner; public class ScannerTest_GE { public static void main(String[] args){ Scanner scan = new Scanner(System.in); String name; // declaration double base, exponent; System.out.println("Enter the base "); base = scan.nextDouble(); System.out.println("Enter the exponent "); exponent = scan.nextDouble(); System.out.println("Enter your name " ); name = scan.next(); System.out.println(name + " the value is "+ Math.pow(base,exponent)); System.out.println(name + " the integer value is "+ (int)Math.pow(base,exponent)); } } // Enter the base // 2 // Enter the exponent // 5 // Enter your name // grace // The value is 32.0 // The integer value is 32