Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions H071201040/PRAKTIKUM-5/P5no1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.Scanner;
public class P5no1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int angka1 = input.nextInt();
int angka2 = input.nextInt();
System.out.println("FPB dari " + angka1 + " dan " + angka2 + " = " + cariFPB(angka1, angka2));

}
public static int cariFPB(int x, int y) {
int z = 0;
int besar = y;
int kecil = x;
if (x > y) {
besar = x;
kecil = y;
}
for(int i = 1; i <= besar; i++) {
if(kecil%i==0 && besar%i==0)
z = i;

}
return z;
}
}

24 changes: 24 additions & 0 deletions H071201040/PRAKTIKUM-5/P5no2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.util.Scanner;
import java.util.Random;

class P5no2 {
public static void main (String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
String serialNumber = generateSerial(n, m);
System.out.println(serialNumber);
}
public static String generateSerial (int n, int m) {
Random random = new Random();
String str = new String();
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
str+=random.nextInt(10);
}
if(i<n)
str+="-";
}
return str;
}
}
15 changes: 15 additions & 0 deletions H071201040/PRAKTIKUM-5/P5no3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.Scanner;
public class P5no3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int usia = input.nextInt();
System.out.println(myDay(usia));
}
public static String myDay(int usia) {
int year = usia/365;
int month = (usia-year*365)/30;
int day = usia-(year*365)-(month*30);
String str = year+" tahun\n"+month+" bulan\n"+day+" hari";
return str;
}
}