Java - Menentukan Bilangan Phytagoras

Contoh program Java menentukan apakah 3 bilangan yang di inputkan merupakan triple phytagoras.

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 

Java Menentukan Bilangan Phytagoras Sukses
Output Bukan Triple Phytagoras


Java Menentukan Bilangan Phytagoras Gagal
Output Triple Phytagoras
Terimakasih, Semoga bermanfaat
Sumber from my friend https://serverrendi.blogspot.co.id

Related Posts:

0 Response to "Java - Menentukan Bilangan Phytagoras"

Post a Comment