DivideByTwo - 5 try 6 7 oneLine = in.readLine 8 x =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.*; public class DivideByTwo { public static void main( String [ ] args ) { /* 1*/ BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) ); /* 2*/ int x; /* 3*/ String oneLine; / /* 4*/ System.out.println( "Enter an integer: " );
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* 5*/ try /* 6*/ { /* 7*/ oneLine = in.readLine( ); /* 8*/ x = Integer.parseInt( oneLine ); /* 9*/ System.out.println( "Half of x is " + ( x / 2 ) ); /*10*/ } /*11*/ catch( Exception e ) /*12*/ { System.out.println( e ); } } }...
View Full Document

Ask a homework question - tutors are online