It's Solved!

public static void displayResult() throws IOException{
		double cost = composeReport();
		try{
			FileWriter fw = new FileWriter("dailyreport.txt", true);
			PrintWriter out = new PrintWriter(fw);
			String output = ("Customer " + report + " for "+  df.format(cost) + " dollars.\n");
			if(buy){
			JOptionPane.showMessageDialog(null, "You receive: \n"
												+  df.format(cost) + " dollars\n"
												+ "We appreciate your business!");
			}else{
				JOptionPane.showMessageDialog(null, "Your charge for the transaction is:\n"
						+ df.format(cost) + " dollars\n"
						+ "We appreciate your business!");
			}
			out.append(output);
			out.close();
			}catch(Exception e){
				e.printStackTrace();
				System.err.println("Error: " + e.getMessage());
			}
	}

I had to add this if statement to get it to give the proper output dialog box for the user. Thanks so much for all the help NormR1!

Your code structure is poor. It is very hard to understand what the code does because you hide important method calls inside of other methods.
The code in the main loop should call each of the required methods one after the other.
With your code structure, there is no way you could reuse any of the methods in another programming project. They are too tightly connected. Each method should do one thing and return a result (or set global variables). The name of the method should be a verb describing what the method does. Some of yours follow this rule, many don't.

Just saw this. How can I start to revamp this code to make it better?

Make every method do one simple thing.
For example your displayResult() method calls the composeReport method.
Those two methods should be called separately by the main loop.
The composeReport method calls some methods that are not part of composing a report.
They also should be moved out of that method.

Ok, I'm not arguing, just trying to understand. I thought it was done correctly based on the assignment? Does this go back to what you were telling me yesterday with the way they had it set up?

Sorry, I did not read your assignment again.
If your assignment says to do it the way you have done it, then I have no more to say, other than: Good luck.

What is your class supposed to teach you?
Is your class going to cover object oriented programming?

I think the goal of this class is to teach basic java to include the use of variables, if statements, while/for loops, and methods. Next class is supposed teach GUIs and object oriented programming.

I suppose sometime some one will talk about program design and the creation and use of methods.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.