I have an issue trying to create a method successfully to get the difference of two integers (sales) and displaying them. I have a working program and it's all good but I need to find a way to add this to what I have. It's not the end if I can't get it but I have a personal interest in it now. Should I post code too? It's two classes....It is a homework question but I want to know for myself. I've been doing this over 10 hours now and have a pretty decent program going but I need this element to finalize my brain and get peace...
________________________________________________________________________________________________________________end of main class
William Kovacs wrote:I have an issue trying to create a method successfully to get the difference of two integers (sales) and displaying them.
1. Please UseCodeTags (←click). And please read the page thoroughly, because some of your lines are far too long. You can use the Edit button to add the tags and break up those enormous lines.
2. I'm not quite sure what your problem is. Given two integers, i1 and i2, the simplest way to display their difference is:
System.out.println(i1 - i2); however I suspect there's more to your problem than just that, so please explain it fully.
Isn't it funny how there's always time and money enough to do it WRONG?
It is not only the lines that are too long (if you look, I have added code tags and broken the lines, so you can see how it is done, but you would have done it better yourself), but the whole thing is too long. You should write 5 lines, compile and run them, and see what happens. Then write another 5 lines, etc. That way you find out much sooner when something goes wrong. As it is, there is too much code for us to read.
One thing I noticed, however, which I didn’t like, is that you are combining different ways to format output. Use printf or DecimalFormat, but not both. I would suggest you get rid of DecimalFormat altogether. Get rid of the \n character too; use the %n tag instead and printf throughout.