দ্বিঘাত সমীকরণের মূল নির্ণয়ের জাভা প্রোগ্রাম (দ্বিঘাত সমীকরণের মূল নির্ণয়)

দ্বিঘাত সমীকরণের মূল নির্ণয়

 import java .util.*;

public class Quadratic {

public static void main(String [ ] args ) {

double a, b, c, x1, x2, determinant;

Scanner in=new Scanner (System.in);

a=in.nextDouble( );

b=in.nextDouble( );

c=in.nextDouble( );

determinant=(b*b-4*a*c);

if( determinant >0 ){

x1 = (-b+Math.sqrt(determinant)) /(2*a);

x2 = (-b+Math.sqrt(determinant)) /(2*a);

System.out.format(“x1 = %.2f and x2 = %.2f”, x1 ,x2 );

}

else if (determinant ==0){

x1 = x2 = -b / ( 2*a );

System.out.format(“x1 = x2 = %.2f ; ” x1);

}

else {

System.out.println(“Roots are imaginary.”);

}

}

}

Next Post Previous Post
No Comment
Add Comment
comment url