View Code of Problem 42

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {	
		Scanner scan = new Scanner(System.in);
			float a = scan.nextFloat();
			float b = scan.nextFloat();
			float c = scan.nextFloat();
		
			float x1 =(float) (-b+Math.sqrt(b*b-4*a*c)) / (a*2); 
			float x2 =(float) (-b-Math.sqrt(b*b-4*a*c)) / (a*2); 
			
			System.out.println(String.format("%.2f", x1)+" "+String.format("%.2f", x2));
			
		scan.close();
		}
}

Double click to view unformatted code.


Back to problem 42