Ronaldoztupang

Quiz Live Coding 2 (2-10-2019)

Oct 1st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. //Soal No.1
  2. import java.io.*;
  3. import java.util.Scanner;
  4.  
  5. public class Solution {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner masuk = new Scanner(System.in);
  9.         long N = masuk.nextLong();
  10.         long x,y;
  11.         x = masuk.nextLong();
  12.         y = masuk.nextLong();
  13.         if((N%x==0)&&(N%y==0)){
  14.             System.out.print("Sangat Takut");
  15.         }
  16.         else if((N%x==0)||(N%y==0)){
  17.             System.out.print("Takut");
  18.         }
  19.         else {
  20.             System.out.print("Tidak Takut");
  21.         }
  22.     }
  23. }
  24. ------------------------------------------------------------------
  25. //Soal No.2
  26. import java.io.*;
  27. import java.util.Scanner;
  28.  
  29. public class Solution {
  30.  
  31.     public static void main(String[] args) {
  32.         Scanner masuk = new Scanner(System.in);
  33.         long M = masuk.nextLong(),N = masuk.nextLong();
  34.         if((M<0)||(N<0)){
  35.             if((M<0)&&(N<0)){
  36.             M = M*-1;
  37.             N = N*-1;
  38.             }
  39.             else if((M<0)&&(N>=0)){
  40.                 M = M*-1;
  41.             }
  42.             else if((N<0)&&(M>=0)){
  43.                 N = N*-1;
  44.             }
  45.         }
  46.         if(M==N){
  47.             System.out.print("Nilai sama");
  48.         }
  49.         else if(M<N){
  50.             System.out.print("Sudah terurut");
  51.         }
  52.         else if(M>N){
  53.             System.out.print(N+" "+M);
  54.         }
  55.     }
  56. }
Add Comment
Please, Sign In to add comment