Hey, thank you for responding. The program runs perfectly but I wrote everything in the userspec function that should actually be under the main function. So I want to move the code around and make it correctly written.
I am struggling with learning functions, can't quite grasp them yet.
The idea behind functions is mostly to be able to reuse certain bits of code easily. They also give you small entities which have one specific task. This makes code more clear, readable and more modular.
In your program, you could, for instance have following functions (I've exaggerated a little bit to make the point clear):
process_order(); //pass necessary variables for these two too of course