You haven't moved your variables to the class, but to the object. They are only in the class if you mark them static.
Beware of writing your code to match a compiler error message; I think the bit in the error message about “non‑static” causes a lot of confusion. I think it make you think there is something “normal” about things being static, and I think should really say that an instance method/field/etc can only be accessed from an instance method.
I think the real problem is that you aren';t getting out of static methods soon enough. The ideal length of the main method is one statement (for some reason main method shorter than one statement have never really caught on). Winston's take on the main() method does show one statement. The first line isn't a statement but a declaration, That means that all the other code needs to go into different methods.
1: You were correct to move the variables out of the main() method.
2: I think you need another class to start off the whole application, and that class should have a main() method. That means you aren't calling a main() method in your original class.
3: Use a file chooser rather than hard‑coding a file name or asking for text input. Come to think of it, haven't I told you that already? Haven't I told you a lot of other things already? Didn't I write something showing how to convert something similar to your app to good OO design here? (That last post needs enhancement, and contains several errors.)
4: I can scarcely envisage a less helpful name for a class than Program6. Well, maybe Program. Make sure your names for everything show what they mean.
I have already told you to create a Price object, maybe put Price objects into a List, and make the Price objects do the calculations. You need to move the code out of the main() method. I think you are gong to have to start again, I am afraid.
Please avoid long lines, which are messing up the formatting of the whole thread. Your line 16 should read like this, and I shall leave you to guess what will happen when you get to line 18. (Hint: it won't be nice.)Another badly‑named variable there, I am afraid. Give that method calll an additional first argument of null.
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.