Contoh program Java menentukan apakah 3 bilangan yang di inputkan merupakan triple phytagoras.
SOURCE CODE
OUTPUT
Terima kasih
Enjoy your day !
SOURCE CODE
import java.io.*;
public class TripelPhytagoras
{
public static void main(String[] args) throws IOException
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int a,b,c,f,g,h,i;
System.out.println("");
System.out.println("Menentukan apakah 3 bilangan itu triple phytagoras");
System.out.println("Jika A2 = B2 + C2");
System.out.println("");
System.out.print("Nilai A : ");
a = Integer.parseInt(input.readLine());
System.out.print("Nilai B : ");
b = Integer.parseInt(input.readLine());
System.out.print("Nilai C : ");
c = Integer.parseInt(input.readLine());
System.out.println("");
f=a*a;
g=b*b;
h=c*c;
i=g+h;
if(f==i){
System.out.println(a + " " + b + " " + c +" merupakan triple phytagoras");
} else {
System.out.println(a + " " + b + " " + c +" bukan merupakan triple phytagoras");
}
}
}
OUTPUT
Output Bukan Triple Phytagoras |
Output Triple Phytagoras |
Terima kasih
Enjoy your day !
EmoticonEmoticon