Java Program
Question:
A quadratic equation is represented as ax 2 + bx + c .
Define a class Roots on the following details:
Class name Roots
Variables/data members
a to store coefficient of x 2
b to store coefficient of x
c to store the constant term
d to store discriminant
Member methods:
Roots(int,int,int) : a parameterized constructor to store the values of a,b and c
void calculate(): to calculate discriminant as d=b 2 – 4*a*c
void display(): to print the nature of roots on following conditions.
Discriminant(d) Nature
If(d>0) Roots are real and unequal
If(d==0) Roots are real and equal
If(d<0) Roots are imaginary and unequal
Write a main method to create object and call the functions as required.
Answers
Answered by
0
Answer:
Java is Class based , object oriented to programming language that is designed to have as few implement depends as possible . . .
Similar questions