The task is to create a simple calculator that opens a file, reads in a line of text that is a simple calculation, writes the result to another file, and repeats. The format of the file will be a separate arithmetic expression on each line. The expression will be a series of numbers and operators alternated, starting and ending with a number, like so: 4 + 3 * 2.3. Each line of the file will have a new expression.
One important item is that we have changed the rules of precedence so that it is always left to right. This makes the programming much easier, and you will have plenty of time to wrestle with techniques for handling proper precedence late. In our system, evaluation is always done left to right. So in the above example, 4 + 3 * 2.3 is 16.1, not 10.9.
outputStream = new PrintWriter(new BufferedWriter(new FileWriter("characteroutput.txt"))); outputStream.println("Some Pig");You will find that some of these methods throw exceptions. You will need to catch them and deal with them gracefully, without crashing.
Scanner p = new Scanner("4 + 3 * 2.3"); double num1 = p.nextDouble(); String op = p.next();etc...