Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //SOAL ALAY
- import java.util.*;
- public class SoalLiveCoding3 {
- public static void main(String[] args) {
- boolean checkAlay = false;
- Scanner in = new Scanner(System.in);
- String kata = in.nextLine();
- String output = "";
- for (int i = 0; i < kata.length(); i++) {
- if(kata.cha(i) == '1' || kata.charAt(i) == '4' || kata.charAt(i) == '9'){
- checkAlay = true;
- }
- }
- if(checkAlay){
- for (int i = kata.length() - 1; i >= 0; i--) {
- switch(kata.charAt(i)){
- case '1':
- output += "i";
- break;
- case '4':
- output += "a";
- break;
- case '9':
- output += "g";
- break;
- default:
- output += kata.charAt(i);
- break;
- }
- }
- System.out.println(output);
- }else{
- System.out.println("Bukan Alay");
- }
- }
- }
- // REFERENSI LAIN SOAL ALAY
- import java.io.*;
- import java.util.*;
- public class Solution {
- public static void main(String[] args) {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
- Scanner in = new Scanner(System.in);
- String input = in.nextLine();
- String balik = "";
- boolean cek = false;
- for(int i = input.length() - 1; i >= 0; i--){
- switch(input.charAt(i)){
- case '1' :
- balik += 'i';
- cek = true;
- break;
- case '4':
- balik += 'a';
- cek = true;
- break;
- case '9':
- balik += 'g';
- cek = true;
- break;
- default:
- balik += input.charAt(i);
- break;
- }
- }
- if (!cek){
- System.out.println("Bukan Alay");
- } else {
- System.out.println(balik);
- }
- }
- }
- //SOAL PRIMA
- import java.util.*;
- public class ForPrima {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- var input = in.nextInt();
- var found = 0;
- var n = in.nextInt() ;
- while (found < n){
- var count = 0 ;
- for (int i = 1; i <= input; i++) {
- if (input % i == 0){
- count++;
- }
- }
- if (count == 2){
- if(found < n - 1){
- System.out.printf("%d ",input);
- }else{
- System.out.printf("%d",input);
- }
- found++;
- }
- input++;
- }
- }
- }
Add Comment
Please, Sign In to add comment