public class QuadraticEquation {
private double a;
private double b;
private double c;
public QuadraticEquation(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
public double getA() {
return a;
}
public void setA(double a) {
this.a = a;
}
public double getB() {
return b;
}
public void setB(double b) {
this.b = b;
}
public double getC() {
return c;
}
public void setC(double c) {
this.c = c;
}
public double getDiscriminant() {
return b * b - 4 * a * c;
}
public boolean hasRealSolution() {
return getDiscriminant() >= 0;
}
}
// Main.java
public class Main {
public static void main(String args[]) {
QuadraticEquation equation = new QuadraticEquation(1, 3, 2);
System.out.println("Discriminant of the equation: " + equation.getDiscriminant());
System.out.println("The equation has real roots: " + equation.hasRealSolution());
}
}
java code Design a class named QuadraticEquation for a quadratic equation with real coefficients ax? +...
Use Python Programming.
Design a class named Quadratic Equation for a quadratic equation ax + bx+c 0. The class contains: • The data fields a, b, and c that represent three coefficients. . An initializer for the arguments for a, b, and c. • Three getter methods for a, b, and c. • A method named get Discriminant() that returns the discriminant, which is b- 4ac The methods named getRoot 1() and getRoot 2() for returning the two roots of...
Java Programming Question 4 (10 points): Solutions for a quadratic equation ax(squared)+bx+c= 0. where a does not equal zero are as follows. r1=( −b+√b(squared)−4ac)/2a r2=(−b−√b(squared)−4ac)/2a if b(squared)−4ac <0, equation doesn’t have real roots. If it is 0 there is one root(r1=r2). Write a Java program to read a,b and c from keyboard and find the roots, if they exist. Note: You need to have a method that takes 3 real values as arguments
In Python. The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula: r1 = (-b + sqrt(b^2 - 4ac) / (2a) and r2 = (-b - sqrt(b^2 - 4ac) / (2a) b^2 - 4ac is called the discriminant of the quadratic equation. If it is positive, the equation has two real roots. If it is zero, the equation has one root. If it is negative, the equation has no...
C++ The roots of the quadratic equation ax² + bx + c = 0, a ≠ 0 are given by the following formula: In this formula, the term b² - 4ac is called the discriminant. If b² - 4ac = 0, then the equation has a single (repeated) root. If b² - 4ac > 0, the equation has two real roots. If b² - 4ac < 0, the equation has two complex roots. Instructions Write a program that prompts the...
Pseudocode and PYTHON source code, thanks! Program 1: Design (pseudocode) and implement (source code) a class (name it QuadraticEquation) that represents a quadratic equation of the form of ax2+ bx + x = 0. The class defines the following variables and methods: Private data field a, b, and c that represent three coefficients. A constructor for the arguments for a, b, and c. Three get methods for a, b, and c. Method getDiscriminant()returns the discriminant value, which is disc =...
Help with MATLAB.
i did like
input('enter the coefficients of a quadratic equation "Ax2 + Bx
+ C = 0"')
fx=(-B+sqrt(B^2+4*A*C))/(2*A);
i just dont know how i can ask the user to input three
(A,B,C)?
thanks!
EXERCISE 6 Ask user to enter the coefficients of a quadratic equation, Ax² + Bx + C = 0, i.e. A, B, and C, and calculate the roots of the equation using the quadratic formula, ., --B+VB? - 4AC 2A
Design a class named Linear Equation for a [2 x 2] system linear equationsax + by = ecx + dy = fand intersection point (x, y):x = (ed -bf)/(ad –bc)?y = (af –ec)/(ad –bc)–?•The class contains data fields a, b, c, d, e, and with get methods.•A constructor with the arguments for a, b, c, d, e,and f.•Six get methods for a, b, c, d, e, and f.•A method named isSolvable() that return the solution for the equation.•The methods getX()and...
Design a class named Account that contains: A private int datafield named id(default 0) A private double datafield named balance(default 0) A no-arg constructor that creates default account A constructor that creates an account with specified id & balance The getter and setter methods for id and balance. Create an object of account class using default constructor and update the balance to 2000$ .
1) Using the Quadratic class you have already developed, make it Comparable. A Quadratic is bigger than another Quadratic if it opens faster. 2) Write a driver for Quadratic.java. In the driver program create a few objects and compare them . then create a list of those objects and sort them. import java.util.*; import java.lang.*; class Quadratic{ private double a,b,c; // Determines/declares the class variables to store the coefficients Quadratic(){ // Determine/declare the default constructor ...
reword m the program into a design document
diregard the m
Write a C++ program that solves a quadratic equation to find its roots. The roots of a quadratic equation ax2 + bx + c = 0 (where a is not zero) are given by the formula -b + b2 - 4ac 2a The value of the discriminant b2 - 4ac determines the nature of roots. If the value of the discriminant is zero, then the equation has a single...