Create a new folder called CSCI130_A3_yourname. Create all of the files indicated below within this folder. For...

70.2K

Verified Solution

Question

Programming

Create a new folder called CSCI130_A3_yourname. Createall of the files indicated below within this folder.

For this assignment you will be creating a total of 2 classesthat meet the definitions below. This assignment will allow theuser to enter in the coefficients for a polynomial function ofdegree 2. The user will then be asked to enter a number. Theprogram will use that number as an argument to the function, andwill print the corresponding function value.

Keep in mind that a second degree polynomial function in generalform looks like:

    f(x) = ax2 + bx + c (here 'a' isthe coefficient of the quadratic term, 'b' is the coefficient ofthe linear term, and 'c' is the constant)

Refer to the image at the bottom of this page to get a betterunderstanding of the logic flow.

CLASSES:

  1. Polynomial - this class should be in a file namedPolynomial.java
  2. Assignment3 - this class should be in a file namedAssignment3.java

CLASS DEFINITIONS:

class Polynomial

Data (instance variables) - all have privateaccess

  • double quadraticCoefficient (this is the coefficient of thequadratic term of the polynomial)
  • double linearCoefficient (this is the coefficient of the linearterm of the polynomial)
  • double constant (this is the constant of the polynomial)

Methods (behaviors) - all have publicaccess

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 theconstant term for the polynomial, and sets the attributesaccordingly

functionValue:

  • Arguments:
    • double arg
  • Return
    • double
  • Behavior
    • Calculates and returns the function value using the argumentarg (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 Polynomialentered) is displayed

After writing the code, do the following:

  • Compile and execute the code. Fix any errors that occur ateither stage. Continue this process until the program runscorrectly.
  • Document the code by putting your name, the date, assignmentnumber, and instructor in comments at the top of the Driver.javafile.
  • Submit your assignment be either:
    • uploading both files within the CSCI130_A3_yournamefolder to Canvas
      OR
    • zipping the entire CSCI130_A3_yourname folder anduploading the zipped file to Canvas

Answer & Explanation Solved by verified expert
3.9 Ratings (707 Votes)
Code in Java class Polynomial private double quadraticCoefficient private double linearCoefficient private double constant Polynomial constructPolynomial constructor calls this instance method public void    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students

Biology
1.2K views

What are the phases of Meiosis? -                                                                                              .                                                                                                                                                                                                        .                                                                                                                                                                                                                                                       Describe independent assortment of chromosomes.__________________________________                                                                                                                                                                                                                                        What is crossing over?                                                                                                         .                                                                                                                                                                                                                                                                                                     . What is the biological significance...