Write a program that reads in a quadratic equation from the keyboard as a string. It should then extract the coefficients as integers and use them to produce a graph showing the curve from the x-axis values -20 to +20.
For simplicity in parsing the string, you need to be able to examine the characters one at a time, and if their numerical equivalent is 0 – 9 (use positive, single-digit coefficients for simplicity’s sake) then record those as one of the three values needed to produce the output. So, you will need to do some reading on the methods available to strings, as well as the character-to-integer conversion method. For example, if the input (again, with no spaces for simplicity) were:
The relevant values for graphing the curve would be 3, 5 and 6. Note that the second value (2) is just an indication of the squaring of x, and should, therefore, be ignored.
A window should appear showing the x/y axes as a cross, and a point for each value along the -20 to + 20 range. Remember to provide a proper offset for your x/y values so that they appear on the screen properly (play with the numbers a bit).
For example, with a 400 by 400 window, my input equation is:
2x2 + 3x + 4
The code extracted the relevant integers 2, 3 and 4, and produced the image below using a 2x2 oval for each “dot.” Since the window is 400 × 400, I ran my loop from -20 to +20, multiplied the horizontal value by 10 and offset it by 200 (so it would appear relative to the middle).
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of