Advertisement
Ronaldoztupang

Jawaban Rias si Fisikawati 2

Oct 23rd, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Solution {
  5.  
  6.     public static void main(String[] args) {
  7.     String s1,s2,s3,s4; int x = 0;
  8.     Scanner masuk = new Scanner(System.in);
  9.     s1 = masuk.nextLine();
  10.     s2 = masuk.nextLine();
  11.         s3 = masuk.nextLine();
  12.         s4 = masuk.nextLine();
  13.         if(s1.equalsIgnoreCase("hilang"))
  14.         {
  15.             x++; s1 = "0";
  16.         }  
  17.         if(s2.equalsIgnoreCase("hilang"))
  18.         {
  19.             x++; s2 = "0";
  20.         }
  21.         if(s3.equalsIgnoreCase("hilang"))
  22.         {
  23.             x++; s3 = "0";
  24.         }
  25.         if(s4.equalsIgnoreCase("hilang"))
  26.         {
  27.             x++; s4 = "0";
  28.         }
  29.         double ep = Double.valueOf(s1);
  30.         double m = Double.valueOf(s2);
  31.         double g = Double.valueOf(s3);
  32.         double h = Double.valueOf(s4);
  33.         if(x>=2)
  34.         {
  35.             System.out.print("GAK ADA");
  36.         }
  37.         else if(x==1)
  38.         { //EP=M.G.H
  39.             if(ep==0)
  40.             {
  41.                 ep = m*g*h;
  42.                 ep = Math.round(ep);
  43.                 System.out.printf("%.2f J",ep);
  44.             }
  45.             else if(m==0)
  46.             {
  47.                 m = ep/(g*h);
  48.                 m = Math.round(m);
  49.                 System.out.printf("%.2f Kg",m);
  50.             }
  51.             else if(g==0)
  52.             {
  53.                 g = ep / (m*h);
  54.                 g = Math.round(g);
  55.                 System.out.printf("%.2f m/s^2",g);
  56.             }
  57.             else if(h==0)
  58.             {
  59.                 h = ep / (m*g);
  60.                 h = Math.round(h);
  61.                 System.out.printf("%.2f m",h);
  62.             }
  63.         }
  64.         else if(x==0)
  65.         {
  66.             if(ep==(m*g*h))
  67.             {
  68.                 System.out.print("WOW");
  69.             }
  70.             else
  71.             {
  72.                 System.out.print("APA SIH");
  73.             }
  74.         }
  75.      
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement