Saddsda
Saddsda
Saddsda
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;
}
}
}
}
}
}
}
1. import java.util.Scanner;
System.out.print("Masukkan : ");
int angka1 = scanner.nextInt();
System.out.print("Masukkan : ");
int angka2 = scanner.nextInt();
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();
}
}
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();
System.out.println();
}
}
4.