import java.io.*; class Arithmetic { public static void main ( String [ ] args ) throws Exception { InputStreamReader isr = new InputStreamReader ( System.in ) ; BufferedReader comingIn = new BufferedReader ( isr ) ; PrintWriter goingOut = new PrintWriter ( System.out , true ) ; char op ; // space to hold a character rep some arithmetic operator int x , y ; // space to store input double answer = 0 ; // space for answer, poss decimal because of div String ask = "Please enter an " ; // more generic this time goingOut.println ( ask + "integer." ) ; x = Integer.parseInt ( comingIn.readLine( ) ) ; goingOut.println ( ask + "operator.") ; op = ( comingIn.readLine( ) ).charAt(0) ; goingOut.println ( ask + "integer.") ; y = Integer.parseInt ( comingIn.readLine( ) ) ; switch ( op ) { case '+' : answer = x + y ; break ; case '-' : answer = x - y ; break ; case '*' : answer = x * y ; break ; case '/' : answer = y!=0 ? (double)x/y : Double.NaN; break; default : goingOut.println( "Sorry, I didn’t understand what you meant ... bye-bye!" ) ; answer = Double.NaN ; } // end switch statement interpreting the arithmetic operation to be performed goingOut.println ( "The value of " +x+ " " +op+ " " +y+ " is " +answer) ; goingOut.println ( "Thanks for using \"Multiplier\". Do come again!" ) ; comingIn.close( ) ; isr.close(); } // end of main method } // end of class Arithmetic