Saddsda

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

016_SALMALIKA SAVITA

20. public class main{


public static void main(String[] args) {
int x = 5;
for (int i = 1; i <= x; i++){
for (int j = 4; j >= i; j--) {
System.out.print(' ');
}
for (int k = 1; k <= i; k++){
System.out.print('*');
}
for (int l = 1; l <= i - 1; l++){
System.out.print('*');
}
System.out.println();
}
}
}

2. public class main {

public static void main(String[] args) {

System.out.println("Mahasiswa Pedia siap tangkap Bjorka");


}
}

19. public class App {


public static void main(String[] args) {
for (int i=0; i< 5; i++){
System.out.println("");
for (int j=0; j< 5; j++){
System.out.print("*");
}
}
}
}

13. contoh masukan 1 :


public class MyClass {
public static void main(String[] args) {
int result = sum(6);
System.out.println(result);
}
public static int sum(int k) {
if (k > 0) {
return k + sum(k - 1);
} else {
return 0;
}
}
}

contoh masukan 2 :
public class MyClass {
public static void main(String[] args) {
int result = sum(5);
System.out.println(result);
}
public static int sum(int k) {
if (k > 0) {
return k + sum(k - 1);
} else {
return 0;
}
}
}

18. public class Main {


public static void main(String[] args) {

System.out.println("falih jago menembak");


System.out.println("ayara jago berenang");
System.out.println("yulia jago pemrograman");
System.out.println("firman jago komputer");
System.out.println("heksom jago design");

}
}

public class Main {


public static void main(String[] args) {

System.out.println("berat badan irham 75,8");


System.out.println("berat badan ayodya 70,4");
System.out.println("berat badan hudson 77,6");
System.out.println("berat badan resna 68,8");
System.out.println("berat badan teguh 80,5");

}
}

1. import java.util.Scanner;

public class UTS {


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

System.out.print("Masukkan : ");
int angka1 = scanner.nextInt();

System.out.print("Masukkan : ");
int angka2 = scanner.nextInt();

int hasil = angka1 + angka2;


System.out.println("hasil " + angka1 + " dan" + angka2 + " adalah: " +
hasil);

scanner.close();
}
}
14. public class App {
public static void main(String[] args) {
char huruf[] = {'j', 'h', 'a', 'm', 'v', 'i', 'o', 'n', 's', 'h', 'i',
'a'};
System.out.print(huruf[0] + " ");
System.out.print(huruf[2] + " ");
System.out.print(huruf[4] + " ");
System.out.print(huruf[11] + " ");
System.out.println();
}
}

15. public class App {


public static void main(String[] args) {
int[] myArr = new int[5];

for (int x = 0; x < 5; x++) {


myArr[x] = 42;
System.out.println(x + ": " + myArr[x]);
}
}
}

3. public class main {


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

System.out.print("Masukkan jumlah bebek (N): ");


int jumlahBebek = input.nextInt();
System.out.print("Masukkan jumlah teman (M): ");
int jumlahTeman = input.nextInt();

int bebekPerTeman = jumlahBebek / jumlahTeman;

int sisaBebek = jumlahBebek % jumlahTeman;

System.out.println("Setiap teman akan menerima " + bebekPerTeman + " ekor


bebek.");
System.out.println("Sisa bebek yang tidak dapat dibagi rata: " +
sisaBebek);

input.close();
}
}

5. import java.util.Scanner;
public class UTS {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Masukkan bilangan bulat N: ");
int N = input.nextInt();

if (N > 0) {
System.out.println("Bilangan bulat yang dimasukkan adalah: " + N);
}
}
}

7. import java.util.Scanner;
public class UTS {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int bil;
System.out.print("Masukan bilangan: ");
bil = scanner.nextInt();

if (bil < 10) {


System.out.println("Satuan");
} else if (bil < 100) {
System.out.println("Puluhan");
} else if (bil < 1000) {
System.out.println("Ratusan");
} else if (bil < 10000) {
System.out.println("Ribuan");
} else if (bil < 100000) {
System.out.println("Puluhribuan");
} else if (bil < 1000000) {
System.out.println("Ratusanribuan");
}
}
}

11. public class UTS {


public static void main(String[] args) {
int kecepatan = 50;
int waktu = 5;

for (int jam = 1; jam <= waktu; jam++) {


int jarak = kecepatan * jam;
System.out.println(jam + " jam = " + jarak + " km");
}
}
}

16. import java.util.Scanner;


public class UTS {
public static void main(String[] args) {
double[] items = {500, 12.4, 94, 45, 3, 81, 1000.9, 85, 90, 1, 35};

Scanner scanner = new Scanner(System.in);


System.out.print("Masukkan diskon: ");
int diskon = scanner.nextInt();
scanner.close();

for (int i = 0; i < items.length; i++) {


double harga_diskon = items[i] * (100 - diskon) / 100;
System.out.print(harga_diskon + " ");
}
}
}
10. import java.util.Scanner;
public class UTS {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

int seconds = input.nextInt();

for (int i = seconds; i >= 0; i--) {


System.out.print(i);
if (i > 0) {
System.out.print(" ");
}
}

System.out.println();
}
}

4.

You might also like