Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I am taking a java class and I am stuck on this problem? Can anyone please help. A one-variable quadratic expression is an arithmetic

Hi, I am taking a java class and I am stuck on this problem? Can anyone please help.

A one-variable quadratic expression is an arithmetic expression of the form ax2 + bx + c where a, b, and c are some fixed numbers (called coefficients) and x is a variable that can take on different values.

Specify (provide specifications), design (provide algorithms), and implement (provide code) a class called Quadratic that can store information about a quadratic expression. The constructor should set all three coefficients to zero, and another method should you to change these coefficients.

There should be accessor methods to retrive the current values of the coefficients. There also should be a method to allow you to evaluate the quadratic expression at a particular value of x (i.e. the method has one parameter x and returns the value of the expression ax2 + bx + c ).

There should also be a clone method to create clones of a quadratic expression as well as an equals method to compare the equality of two quadratic expressions. Two quadratic expressions are equal if their coefficients a,b, and c are equal.

Also write the following static methods to perform these indicated operations:

public static Quadratic sum(Quadratic q1, Quadratic q2)

//postcondition: the return value is the quadratic expression obtained by adding q1 and q2. For example, the coefficient c of the return value is the sum of q1's c and q2's c.

public static Quadratic scale(double r, Quadratic q)

//postcondition: the return value is the quadratic expression obtained by multiplying each of q's coefficient by the number r.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions