Question: import java.util.Scanner; public class Week3_QuadraticFormula { public static void main(String[] args) { double a, b, c, x, y; Scanner keyboard = new Scanner(System.in); System.out.println(Input the

import java.util.Scanner; public class Week3_QuadraticFormula

{

public static void main(String[] args) {

double a, b, c, x, y; Scanner keyboard = new Scanner(System.in);

System.out.println("Input the value of a: "); a = keyboard.nextDouble();

System.out.println("Input the value of b: "); b = keyboard.nextDouble();

System.out.println("Input the value of c: "); c = keyboard.nextDouble();

x = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); y = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);

System.out.println("The solution for x is " + x);

System.out.println("The solution for y is " + y);

}

}


 

Add validation checks (IFs) to this program to make sure the quadratic formula will work with the data.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

You can add validation checks to ensure that the quadratic formula works with the provided data Spec... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!