FPB dan KPK Menggunakan Java (console)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class kpkfpb | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner baca = new Scanner(System.in); | |
int a; | |
int b; | |
int c; | |
int fpb; | |
int kpk; | |
int x; | |
boolean ulang = true; | |
do | |
{ | |
System.out.print("\nmasukkan dua buah angka: "); | |
a = baca.nextInt(); | |
baca.nextLine(); | |
System.out.print(" dan "); | |
b = baca.nextInt(); | |
baca.nextLine(); | |
x = a * b; | |
do | |
{ | |
c = a % b; | |
a = b; | |
b = c; | |
} | |
while (b != 0); | |
fpb = a; | |
kpk = x / fpb; | |
System.out.println("\nkpk = "+kpk); | |
System.out.println("fpb = "+fpb); | |
ulang = true; | |
} | |
while | |
(ulang!=false); | |
} | |
} |
hadeh, pusing liatnya, saya kurang paham dengan pengkodean nih.
ReplyDelete