#JGRASP WEDGE2: EXIT CODE FOR PROCESS IS 1 CODE#
Use what this Java™ Tutorials section describes instead.ĭon't put all your code in the main method. If you create a new file writer wrongly, you will end up with only the most recent line in the file at all.ĭon't call close(). Use one writer to write the entire list of prices. Maybe with its toString() method.ĭon't create a new buffered writer for each line. Once you have got the Price object to calculate the tax, etc., you can easily get all the details out of it to write to your file. That should be able to calculate the tax for you. Use a file chooser instead.ĭo you have some sort of Price object you can put into a List? As you read the file, create a new Price object. Use %n (in the format() method) or BufferedWriter#newLine() (I think) instead.ĭon't use an option pane to find files. Don't spend lots of time converting your numbers to Strings and vice versa.ĭon't use \n. Add the Swing code later when you have your app working.ĭon't use doubles for money.
![jgrasp wedge2: exit code for process is 1 jgrasp wedge2: exit code for process is 1](https://courses.cs.washington.edu/courses/cse143/11sp/images/jgrasp2.png)
Get something running at the command line not using any Swing code at all. Are you actually using that Process?ĭon't mix GUI code with your logic. You can do that with a PrintStream, BufferedWriter, Formatter, etc. JOptionPane.showMessageDialog(null, "Thank you for using the Price Calculator Program! Your receipt is stored in the file named priceTotals.txt", "Thank you", JOptionPane.PLAIN_MESSAGE) Ĭampbell Ritchie wrote:Why are you creating a new Process? You don't need to use NotePad to write a text file. OutFile.printf("The total price is: $" + totalPrice) OutFile.printf("The tax on the items is: $" + tax)
![jgrasp wedge2: exit code for process is 1 jgrasp wedge2: exit code for process is 1](https://media.cheggcdn.com/study/44d/44dd592e-bd44-4aff-9c37-f54e35cce862/image.png)
OutFile.printf("The subtotal is: $" + subtotal) loop to read any number of prices from the input file PrintStream out = new PrintStream(new File("priceTotals.txt"))
![jgrasp wedge2: exit code for process is 1 jgrasp wedge2: exit code for process is 1](https://users.csc.calpoly.edu/~akeen/courses/csc101/references/pics/path.jpg)
create printstream object for the output file Scanner input = new Scanner (new File("prices.txt")) If (!file.exists()) //if the file is not found, tell user and create new file Please enter the name of the input file and press OK.",JOptionPane.QUESTION_MESSAGE) ĭblprices = Double.parseDouble(strprices) Strprices = JOptionPane.showInputDialog("Welcome to the Price Calculator Program. Public static void main (String args) throws FileNotFoundException Super confused on what I am doing wrong hereĭouble sum, subtotal, tax, totalPrice, prices I was getting errors like crazy before, but I moved my variables from main to class, now I am getting error messages in my class.