[Solved]Java Programs 3 Quadraticooptestjava 5 Points Algebra Solve Quadratic Equations Using Oop Q37158890
Java Programs(3)
QuadraticOOPTest.java (5 points)
Algebra: solve quadratic equations using OOP paradigm. This is amodification
of the HW2 programming question.
The two roots of a quadratic equation ax2 + bx + c = 0 can beobtained using
the following formula:
r1 = −b+p
b2−4ac
2a , r2 = −b−
p
b2−4ac
2a
b2 − 4ac is called the discriminant of the quadratic equation. Ifit is positive,
the equation has two real roots. If it is zero, the equation hasone root. If it is
negative, the equation has no real roots. Note that you can useMath.pow(x,
0.5) to compute p
x.
You need to write the QuadraticOOP class to return the threesolutions (5.0,
-0.3819660112501051, and -2.618033988749895) from a equationx2+3x+1 == 0.
1
1. You need to write a constructor that has a, b, c (to representan equation
ax2 + bx + c = 0) as arguments.
2. You need to implmenet the getDiscriminant() method that returnsthe
discriminant of the quadratic equation.
3. You need to implement getSolution1() that returns r1 andgetSolution2()
that returns r2.
4. You don’t have to implement any error processing routine.
3.2 FanTest.java (5 points)
Design a class named Fan to represent an electric fan. The classcontains:
• You need to make three constants named SLOW, MEDIUM, andFAST
with values 1, 2, and 3 to denote fan speed.
• You need to have the following member fields (member variables ordata
fields)
– A private int data field named speed that specifies the speed ofthe
fan (the default is SLOW).
– A private boolean data field named on that specifies whether thefan
is on(the default is false).
– A private double data field named radius that specifies theradius of
the fan (the default is 5).
– A string data field named color that specifies the color of thefan(the
default is blue).
• You need to have accessor methods to access all four memberfields.
– For example, the speed private data field should have getSpeed()and
setSpeed().
• You need to make a default constructor (without anyaruguments).
The main method in FanTest should returan all trues.
3.3 DateTest.java (10 points)
In this program, you learn to use Java’s Date class to solve daterelated problems.
Write a program that creates (1) a Date object, (2) sets itselapsed time to
10000, 100000, 1000000, 10000000, 100000000, 1000000000,10000000000, and
100000000000 (read hint or textbook if you don’t understand whatdoes this mean)
and (3) displays the date and time using the toString() method,respectively.
You should have the output as follows:
Wed Dec 31 19:00:10 EST 1969
Wed Dec 31 19:01:40 EST 1969
Wed Dec 31 19:16:40 EST 1969
Wed Dec 31 21:46:40 EST 1969
Thu Jan 01 22:46:40 EST 1970
2
Mon Jan 12 08:46:40 EST 1970
Sun Apr 26 13:46:40 EDT 1970
Sat Mar 03 04:46:40 EST 1973
Hint: You should instantiate a Date object, and invoke setTime()of
the Date object to give argument 10000, 100000, and on.
// instantiate Date object
Date date = ???
int count = 1;
long time = 10000; // why it’s important you use `long` datatype?
while (count <= 8) {
// use setTime(time) method of Date object to set time
???
count++;
time *= 10; // you can increase time to setup new time
// print out
}
Expert Answer
Answer to Java Programs(3) QuadraticOOPTest.java (5 points) Algebra: solve quadratic equations using OOP paradigm. This is a modif… . . .
OR

