Question: Create a new project in jdoodle called Assignment3. For this assignment you will be creating a total of 2 classes that meet the definitions below.
Create a new project in jdoodle called "Assignment3". For this assignment you will be creating a total of 2 classes that meet the definitions below. This assignment will allow the user to enter in the coefficients for a polynomial function of degree 2. The user will then be asked to enter a number. The program will use that number as an argument to the function, and will print the corresponding function value. Keep in mind that a second degree polynomial function in general form looks like:
f(x) = ax2 + bx + c (here a is the coefficient of the quadratic term, b is the coefficient of the linear term, and c is the constant)
Data (attributes) - all have private access
double quadraticCoefficient (this is the coefficient of the quadratic term of the polynomial)
double linearCoefficient (this is the coefficient of the linear term of the polynomial)
double constant (this is the constant of the polynomial)
Methods (behaviors) - all have public access
constructor:
Arguments:
None
Return
None
Behavior
Calls Polynomial's constructPolynomial instance method
constructPolynomial:
Arguments:
None
Return
None
Behavior
Allows user to enter the necessary coefficients and the constant term for the polynomial, and sets the attributes accordingly
functionValue:
Arguments:
double arg
Return
double
Behavior
Calculates and returns the function value using the argument arg (for example, if the user entered the polynomial 3x2 + 2x + 7, then functionValue(3) would return 40)
displaySelf:
Arguments:
None
Return
None
Behavior
Neatly displays the polynomial entered by the user
class Assignment3
Methods
public static void main(String[] args):
Arguments:
String[] args
Return:
None
Behavior (see image below for clarification):
The polynomial is constructed
The user is asked for the argument to the function
The polynomial is displayed
The function value (based on the argument and Polynomial entered) is displayed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
