@FarzanaAlya/

Final 40% Project-1

Java

Ubah aturacara berikut mengikut formula atau sturuktur ayat mengikut citarasa tersendiri. Markah diberi berdasarkan kreativiti anda.

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.Scanner;
import java.lang.Math;

class Main{     
public static void main(String[] args){
  Scanner in = new Scanner(System.in);
  double a = 0;
  double b = 0;
  double c = 0;
  
  System.out.println(" Pythagorian Theorem Solver");
  System.out.println("MACAM MANA NAK KIRA NI? SENANG KE SUSAH?");
  System.out.println("Press 1 for SIDE A");
  System.out.println("Press 2 for SIDE B");
  System.out.println("Press 3 for SIDE C");
  int z = in.nextInt();

  if (z == 1){
  System.out.println("Input B: ");
    b = in.nextDouble();
    System.out.print("Input C: ");
    c = in.nextDouble();
    a = Math.sqrt(Math.pow(c,2) - Math.pow(b,2)); 
    System.out.print("A = ");
    System.out.print(a);
  }

  else if(z == 2){
  System.out.println("Input A: ");
  a = in.nextDouble();
  System.out.println("Input C: ");
  c = in.nextDouble();
  b = Math.sqrt(Math.pow(c,2) - Math.pow(a,2));
  System.out.println("B = ");
  System.out.println(b);
  }
  else if(z == 3){
  System.out.print(" Input A: ");
  a = in.nextDouble();
  System.out.print( "Input B: ");
  b = in.nextDouble();
  c = Math.sqrt(Math.pow(a,2) + Math.pow(b,2));
  System.out.print("C is ");
  System.out.println(c);
  } 
  {
    System.out.println("SEMOGA BERMANFAAT HOHO... SELAMAT HARI RAYA!!!");
  }
  }
 }