August 2004
Intermediate to advanced
480 pages
9h 41m
English
This program demonstrates how you might write a simple calculator in Java. It incorporates a number of the programming constructs we've covered so far in this book, and it could be usefully incorporated into other applications. The main thing it does that is of interest here is that it uses the standard input and shows how to read user-entered data in a complete, working app.
It demonstrates using File I/O (BufferedReader and InputStreamReader), using regular expressions, and exception handling.
package net.javagarage.apps.calculator; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; /**<p> * Demos a working ...
Read now
Unlock full access