Concept
How can quadratic-equation inputs be provided as command-line arguments?
ComputerScienceOne / Computing Quadratic Roots
"This program was interactive. As an alternative, we could have read all three of the inputs as command line arguments, converting them to floating point numbers. Lines 12–17 in the program could have been changed to a = atof(argv[1]); b = atof(argv[2]); c = atof(argv[3]); Finally, think about the possible inputs a user could provide that may cause problems for this program. For example: What if the user entered zero for a? What if the user entered some combination such that b^2 < 4ac? What if the user entered non-numeric values? For the command line argument version, what if the user provided less than three arguments? Or more? How might we prevent the consequences of such bad inputs? How might we handle the event that a user enters bad input and how do we communicate these errors to the user? To begin to resolve these issues, we’ll need conditionals."
Related Ideas
- How can a PHP program prompt for the coefficients of a quadratic polynomial?ComputerScienceOne · Computing Quadratic Roots
- How do argc and argv provide and convert command-line arguments?ComputerScienceOne · The cmain() Function
- What kinds of user input can cause problems in a quadratic-roots program?ComputerScienceOne · Computing Quadratic Roots
- How can conditionals handle invalid inputs and special cases in a quadratic roots program?ComputerScienceOne · Quadratic Roots Revisited
- How can conditionals verify the number of command line arguments?ComputerScienceOne · Life & Taxes
- How can conditionals handle invalid and special cases in a quadratic roots program?ComputerScienceOne · Quadratic Roots Revisited
- How does the Java quadratic roots program check errors and calculate its roots?ComputerScienceOne · Quadratic Roots Revisited
- How does a PHP script use entry points and command line arguments?ComputerScienceOne · Entry Point & Command Line Arguments