User Input and Error Handling
Hans Petter Langtangen · Texts in computational science and engineering · 2016
This chapter starts with describing four different ways of reading data into a program: let the user answer questions in a dialog in the terminal window (Sect. 4.1), let the user provide input on the command line (Sect. 4.2), let the user provide input data in a file (Sect. 4.5), let the user write input data in a graphical interface (Sect. 4.8). Even if your program works perfectly, wrong input data from the user may cause the program to produce wrong answers or even crash. Checking that the input data are correct is important, and Sect. 4.7 tells you how to do this with so-called exceptions.