switch ( choice )
{
case '+':
System.out.printf( "The answer is: %1$.4f.\n", first + second );
break;
case '-':
System.out.printf( "The answer is: %1$.4f.\n", first - second );
break;
case '*':
System.out.printf( "The answer is: %1$.4f.\n", first * second );
break;
case '/':
if( second != 0 )
System.out.printf( "The answer is: %1$.4f.\n", first / second );
else
System.out.println( "Can't divide by zero." );
break;
default :
System.out.println( "You have entered an invalid operation. Try again." );
break;
}
switch ( choice ) { case ‘+’: System.out.printf( The answer is: %1$.4f.\n, first +
Share
1 Answer