Hey everyone, need a little help. For some reason I am horrible at file I/O and always have trouble with it. Well my problem, I have a calculator class that shows a user a menu, they then pick a choice and enter 2 numbers and get the sum from w/e choice they picked. I have that all up and working. The last part of the assignment is to log every choice the user picks until he ends the program.
Calculator program in Java is used by programmer to add, subtract, multiply or divide two integer numbers that are input by system. In the given example a class. Here is the source for the simple calculator shown at the left. It's divided into two source files. Main and GUI (Calc.java) - This is implemented as a subclass of.
For example the log file would look like this: 4+5=9 3-5=-2 7*7=49 ect ect ect Just a file that someone can go in at the end of the program and just see a simple view of what he entered in order and the results. I get the file to be created but when I open it, it is blank. Here's the code: •. Actually the problem is that by default, when a file is opened, it is overwritten and since the file opening is in your do-while loop, when the user enter 99 it still opens the file, but writes nothing to it, therefore the empty file. Either open and close the file outside the loop and/or open it in 'append mode' depending on the exact behavior you are looking for. I also double-checked the PrintWriter thing and using a would be easier since you don't need to create the FileWriter first, you can give it the 'File' object or even just the file name. Scratch that about not getting the PrintStream to work, I forgot to add the import for PrintStream.
It is working great now. Craigslist Cash Cow Pdf on this page. Just need to fix the 99 not quitting right away.