Nah bawha kita ketahui rumus mencari Determinan adalah :
D = b*b-(4*.c).
Apabila :
D = 0 --> Akar kembar
D > 0 --> Akar Beda
D < 0 --> Akar Imajiner
Sesuai dengan Rumus makan inputan ke dalam program adalalah :
- Nilai a
- Nilai b
- dan Nilai c
//---------------------------------------------------------------------------
import java.util.*;
public class Determinan
{
public static void main(String [] args)
{
Scanner masuk = new Scanner (System.in);
int a,b,c,D;
double x,x1,x2,Xriil,XImajiner;
System.out.println("\n\nPerhitungan akar-akar determinan");
System.out.println("masukan koefisien a : ");
a = masuk.nextInt();
System.out.println("masukan koefisien b : ");
b = masuk.nextInt();
System.out.println("masukan koefisien c : ");
c = masuk.nextInt();
D = b*b-4*a*c;
System.out.println("Diskriminan = "+D);
System.out.println("Akar persamaan a,b,c ");
if(D>0)
{
x1 =(-b+(Math.sqrt(D))/(2*a));
x2 =(-b-(Math.sqrt(D))/(2*a));
System.out.println("X1 = "+x1);
System.out.println("X2 = "+x2);
}
else if (D == 0)
{
x= -b/(2*a);
System.out.println("X1 = X2 = "+x);
}
else
{
Xriil = -b/(2*a);
XImajiner =Math.sqrt(-D)/(2*a);
System.out.println("\nAkar Imajiner : ");
System.out.println("X1 :"+Xriil);
System.out.println(XImajiner);
System.out.println("X2 :"+Xriil);
System.out.println(XImajiner);
}
}
}
//--------------------------------------------------------------------------
Silahkan yang mu Download Programnya Di Sini
Semoga bermanfaat...!!
0 komentar:
Posting Komentar