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
61 changes: 61 additions & 0 deletions H071201015/PRAKTIKUM-3/No1pp3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import java.util.Scanner;

public class No1pp3 {
public static void main(String[] args) {
Scanner value = new Scanner(System.in);

System.out.println("Input x dan y");
int x = value.nextInt();
int y = value.nextInt();

if (x == y) {
System.out.println("Invalid!");
System.exit(-1);
}
else if (x < y){
if (x % 2 == 0) {
System.out.println(x + " genap negatif");
}
else {
System.out.println(x + " ganjil negatif");
}
}
else {
int temp = x;
x = y;
y = temp;

if (x % 2 == 0) {
System.out.println(x + " genap negatif");
}
else {
System.out.println(x + " ganjil negatif");
}
}

while (x < y) {
x = x + 1;

if (x > 0) {
if (x % 2 == 0) {
System.out.println(x + " genap positif");
}
else {
System.out.println(x + " ganjil positif");
}
}
else if(x < 0) {
if (x % 2 == 0) {
System.out.println(x + " genap negatif");
}
else {
System.out.println(x + " ganjil positif");
}
}
else {
System.out.println("0 nol");
}
}
value.close();
}
}
26 changes: 26 additions & 0 deletions H071201015/PRAKTIKUM-3/No2pp3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.Scanner;

class No2pp3{

public static void main(String[] args) {
Scanner value = new Scanner(System.in);
int count = 0;

System.out.println("-- MENCETAK BILANGAN --");
System.out.println("Input berapa kolom yang anda inginkan : ");
int x = value.nextInt();
System.out.println("input berapa bilangan terkahir :");
int y = value.nextInt();

for(int j = 1;j <= y;j++) {
count += 1;
System.out.print(j + " ");

if (count == x) {
count = 0;
System.out.println(" ");
}
}
value.close();
}
}
26 changes: 26 additions & 0 deletions H071201015/PRAKTIKUM-3/No3pp3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.Scanner;

public class No3pp3 {

public static void main(String[] args) {
Scanner value = new Scanner (System.in);

System.out.println("Input angka : ");
int n = value.nextInt();
int a = 0;
int b = 1;
int next ;
int count = 2;
System.out.print(a + " ");
System.out.print(b + " ");

for (int i = 0; count < n; i++){
next = a + b;
System.out.print(next + " ");
a = b;
b = next;
count = count + 1;
}
value.close();
}
}
109 changes: 109 additions & 0 deletions H071201015/PRAKTIKUM-3/No4pp3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import java.util.Scanner;

class No4pp3{
public static void main(String[] args) {
Scanner value = new Scanner(System.in);

System.out.println("^***^ Menghitung Kembalian ^***^");
System.out.println("HARGA BARANG (Rp.) :");
int x = value.nextInt();
System.out.println("Uang yang dibayarkan (Rp.) : ");
int y = value.nextInt();

int sum1 = 0;
int sum2 = 0;
int sum3 = 0;
int sum4 = 0;
int sum5 = 0;
int sum6 = 0;
int sum7 = 0;

int z = y - x;

while (z >= 0) {

if (z >= 100000) {
sum1 = sum1 + 1;
z = z - 100000;
}

else {
break;
}
}

while (z > 0) {
if (z >= 50000 ){
sum2 += 1;
z = z - 50000;
}
else {
break;
}
}

while (z > 0) {

if (z >= 20000) {
sum3 += 1;
z = z-20000;
}
else {
break;
}
}

while (z > 0) {

if (z >= 10000){
sum4 +=1;
z = z - 10000;
}
else {
break;
}
}

while (z > 0){

if (z >= 5000){
sum5 +=1;
z = z - 5000;
}
else {
break;
}
}

while (z > 0){

if (z >= 2000){
sum6 +=1;
z = z - 2000;
}
else {
break;
}
}

while (z > 0){

if (z >= 1000){
sum7 +=1;
z = z - 1000;
}
else {
break;
}
}
System.out.println("Kembalian : ");
System.out.println(sum1 + " uang Rp. 100.000");
System.out.println(sum2 + " uang Rp. 50.000");
System.out.println(sum3 + " uang Rp. 20.000");
System.out.println(sum4 + " uang Rp. 10.000");
System.out.println(sum5 + " uang Rp. 5.000");
System.out.println(sum6 + " uang Rp. 2.000");
System.out.println(sum7 + " uang Rp. 1.000");
value.close();
}
}
68 changes: 68 additions & 0 deletions H071201015/PRAKTIKUM-3/No5pp3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import java.util.Scanner;

class No5pp3{
public static void main(String[] args) {
Scanner value = new Scanner(System.in);
int Jam, Menit, Detik;
float x;

System.out.println("Input derajat : ");
while ( value.hasNextFloat() ){
x = value.nextFloat();

if (x >= 360){
System.out.println("Error");
break;
}

float y = x * 240f + 21600f;
Detik = ((int)y % 60);
Jam = ((int)y / 60);
Menit = (Jam % 60);
Jam = (Jam / 60);

if (Jam < 12){
System.out.println("Selamat Pagi");
System.out.printf("%02d", Jam);
System.out.printf(":");
System.out.printf("%02d", Menit);
System.out.printf(":");
System.out.printf("%02d\n", Detik);
}
else if (Jam >= 12 & Jam < 15 ){
System.out.println("Selamat Siang");
System.out.printf("%02d", Jam);
System.out.printf(":");
System.out.printf("%02d", Menit);
System.out.printf(":");
System.out.printf("%02d\n", Detik);
}
else if (Jam >= 15 && Jam < 18){
System.out.println("Selamat Sore");
System.out.printf("%02d", Jam);
System.out.printf(":");
System.out.printf("%02d", Menit);
System.out.printf(":");
System.out.printf("%02d\n", Detik);
}
else if (Jam >= 18 && Jam < 24){
System.out.println("Selamat Malam");
System.out.printf("%02d", Jam);
System.out.printf(":");
System.out.printf("%02d", Menit);
System.out.printf(":");
System.out.printf("%02d\n", Detik);
}
else {
Jam = Jam - 24;
System.out.println("Selamat Pagi");
System.out.printf("%02d", Jam);
System.out.printf(":");
System.out.printf("%02d", Menit);
System.out.printf(":");
System.out.printf("%02d\n", Detik);
}
}
value.close();
}
}
45 changes: 45 additions & 0 deletions H071201015/PRAKTIKUM-4/No1pp4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import java.util.Scanner;

class No1pp4 {
public static void main(String[] args) {

Scanner val = new Scanner(System.in);
int n = val.nextInt();
int[] bil = new int[n];
int big = 0;

for (int i = 0;i < n ;i++ ) {
bil[i] = val.nextInt();
}

big = bil[0];
for (int i = 0; i< n;i++){
if (big < bil[i]) {
big = bil[i];
}
}

for (int h = 0; h < n -1 ;h++){
for (int l = h +1;l < n ;l++ ) {
int count = 0;
for (int m = 1;m < big ;m++ ) {
if (bil[h] % m == 0 && bil[l] % m == 0) {
count++;
}
if (bil[h] % 2 == 0 && bil[l] % 2 == 0) {
System.out.print("");
}
}
if (count == 1) {
System.out.print(bil[h] + " " + bil[l]);
System.out.println(" ");
}
else{
System.out.print("");
}
}
}

val.close();
}
}
46 changes: 46 additions & 0 deletions H071201015/PRAKTIKUM-4/No2pp4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import java.util.Scanner;

class No2pp4 {
public static void main(String[] args) {
Scanner val = new Scanner(System.in);
int i = val.nextInt();
int j = val.nextInt();
int k = val.nextInt();

int[][] mat1 = new int [i][j];
int[][] mat2 = new int [j][k];
int[][] mat3 = new int [i][k];

System.out.println("input elemen matriks a");
for (int l = 0;l < i ;l++ ) {
for (int m = 0;m < j ;m++ ) {
mat1[l][m] = val.nextInt();
}
}
System.out.println("input elemen matriks b");
for (int l = 0;l < j ;l++ ) {
for (int m = 0;m < k ;m++ ) {
mat2[l][m] = val.nextInt();
}
}
System.out.println();
//System.out.println("work");

for (int l = 0;l < i ;l++ ) {
for (int m = 0;m < k ;m++ ){
for (int n = 0;n < j ;n++ ) {
mat3[l][m] += mat1[l][n] * mat2[n][m];
}
}
}
System.out.println("");
System.out.println("hasil perkalian matriks a dan matriks b");
for (int l = 0;l < i ;l++ ) {
for (int m = 0;m < k ;m++ ) {
System.out.print( mat3[l][m] + " ");
}
System.out.println(' ');
}
val.close();
}
}
Loading