subject

1. A class Linear is defined as follows. class Linear {

pr ivate :

double a0 ;

double a1 ;

pub l ic :

Linear (double , double) ;

double substitute (double) ;

void display () ;

} ;

Linear represents a linear expression in the form of

a0x + a1. (1)

In other words, a0 and a1 are a0 and a1 respectively in the class definition. The function substitute

computes and returns the value of (1) when x is substituted by the input argument of substitute.

The display function displays the expression (1) in the form of

a0 + a1*x

Write

(a) the two-argument constructor,

(b) the member function substitute and

(c) the member function display

of Linear.

Then derive Quadratic from Linear to handle quadratic expression objects in the form of

a0 + a1x + a2x

(2)

Include a2 of type double as the private member of Quadratic. Provide a three-argument constructor

for Quadratic. Override the member functions substitute and display. The substitute function

in Quadratic evaluates and returns (2) by substituting the value passed into the equation. The display

function of Quadratic prints the quadratic expression in the form of

a0 + a1*x + a2*x^2

Utilize the functions in Linear whenever possible. Explain how a product between two linear expressions can be computed in your program. In which class should the calculation be done?

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:30
You need to write some code that responds to a text change in a jtextfield. how can you do that? create a class that implements the interface actionlistener and override the method textfieldchanged create a class that extends the superclass actionlistener and override the method actionperformed create a class that implements the interface actionlistener and override the method actionperformed create a class that extends the superclass actionlistener and override the method textfieldchanged
Answers: 2
question
Computers and Technology, 22.06.2019 22:40
When you type the pwd command, you notice that your current location on the linux filesystem is the /usr/local directory. answer the following questions, assuming that your current directory is /usr/local for each question. a. which command could you use to change to the /usr directory using an absolute pathname? b. which command could you use to change to the /usr directory using a relative pathname? c. which command could you use to change to the /usr/local/share/info directory using an absolute pathname? d. which command could you use to change to the /usr/local/share/info directory using a relative pathname? e. which command could you use to change to the /etc directory using an absolute pathname? f. which command could you use to change to the /etc directory using a relative pathname?
Answers: 3
question
Computers and Technology, 23.06.2019 12:10
2. fabulously fit offers memberships for$35 per month plus a $50 enrollmentfee. the fitness studio offersmemberships for $40 per month plus a$35 enrollment fee. in how many monthswill the fitness clubs cost the same? what will the cost be?
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
The keyboard usually has six rows of keys. which of the following is not one of the key group categories? letter keys number keys control keys graphic keys
Answers: 1
You know the right answer?
1. A class Linear is defined as follows. class Linear {

pr ivate :

double a0...
Questions
question
Chemistry, 15.09.2021 18:30
question
Biology, 15.09.2021 18:40
question
Spanish, 15.09.2021 18:40
Questions on the website: 13722363