logo Use CA10RAM to get 10%* Discount.
Order Nowlogo

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.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

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:

3x2+5x+6

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).

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

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. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

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

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

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

. 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 Sea Ports. Here are the classes and their instance variables we wish to define:

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

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

904 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

981 Answers

Hire Me
expert
Husnain SaeedComputer science

741 Answers

Hire Me
expert
Atharva PatilComputer science

672 Answers

Hire Me