Langkah-langkahnya seperti di bawah:
1. Buka repl dulu..ataupun boleh tekan link ni..( https://repl.it/ )
2. Lepas korang dah log in..dia akan tulis seperti gambar di bawah :
Lepas tu, tekan dekat button student... and dia akan keluar macam gambar bawah ni:
Lepas tu, tekan project40%...and dia akan keluar macam gambar bawah ni..
P/s: Farah aku guna kau punya tau..TQ |
ataupun macam bawah ni :
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("Press 1 for A side");
System.out.println("Press 2 for B side");
System.out.println("Press 3 for C side");
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.println(a);
}
if (z == 2){
System.out.println("Input A");
a = in.nextDouble();
System.out.print("Input C");
c = in.nextDouble();
b = Math.sqrt(Math.pow(c,2) - Math.pow(a,2));
System.out.print(" B = ");
System.out.println(b);
}
if (z == 3){
System.out.println("Input A");
a = in.nextDouble();
System.out.print("Input B");
b = in.nextDouble();
c = Math.sqrt(Math.pow(c,2) - Math.pow(b,2));
System.out.print(" C = ");
System.out.println(c);
}
{
System.out.println("K,Bye.. Malas nak layan kau..");
}
}
}
4. Next, korang kena delete perkataanan yang ada dalam kotak ni tau :
int z = in.nextInt();5. Kalau dah delete nanti hasil dia akan jadi macam ni :
if (z == 1){
}
if (z == 2){
System.out.println("Input A");
a = in.nextDouble();
System.out.print("Input C");
c = in.nextDouble();
b = Math.sqrt(Math.pow(c,2) - Math.pow(a,2));
System.out.print(" B = ");
System.out.println(b);
}
if (z == 3){
System.out.println("Input A");
a = in.nextDouble();
System.out.print("Input B");
b = in.nextDouble();
c = Math.sqrt(Math.pow(c,2) - Math.pow(b,2));
System.out.print(" C = ");
System.out.println(c);
}
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("Press 1 for A side");
System.out.println("Press 2 for B side");
System.out.println("Press 3 for C side");
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.println(a);
{
System.out.println("K,Bye.. Malas nak layan kau..");
}
}
}
6. Kemudian tukarkan ayat warna merah dalam bracket tu dengan ayat sendiri..contoh :
System.out.println("Press 1 for A side");
System.out.println("Press 2 for B side");
System.out.println("Press 3 for C side");
(p/s: klu dkt ^ ni maksudnya dia ad 3 ayat)
TUKAR JADI
System.out.println("Tak tahu cara nk kira area..");
System.out.println("area rectangle/square....");
(p/s:kalau ^ ni 2 ayat je)
*kalau korang nak 1 atau 2 ayat, so just delete je..
7. Lepas tu tukar yang ni pulak..
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 = ");
Jadi macam ni..ni contoh je tau :
System.out.println("panjang");
b = in.nextDouble();
System.out.print("lebar");
c = in.nextDouble();
a = b*c
System.out.print(" area = ");
8. So, nanti hasil dia akan jadi macam ni :
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("HYE...Guys!!!");
System.out.println(" tak tahu cara nak kira area?");
System.out.println("*********************************************************");
System.out.println("panjang");
b = in.nextDouble();
System.out.print("lebar");
c = in.nextDouble();
a = b*c;
System.out.print(" area = ");
System.out.println(a);
{
System.out.println("OK BYE..!!");
}
}
}
(p/s: jangan tiru bulat2..boleh tukar ayat yg warna merah tu dengan ayat korang sendiri)
(yang simbol * tu saje je nak buat pembahagian kalau x nk buat pon tak pe)
9. Okay.. Sekarang dah boleh tekan RUN..
10. kalau sape nk buat volume kena tambah:
10. kalau sape nk buat volume kena tambah:
tambah double d = 0; dekat bawah double c = 0;kalau nak tengok atau try boleh tekan link ni:
tambah
System.out.print("tinggi");
d = in.nextDouble();
dekat bawah
System.out.print("lebar");
c = in.nextDouble();
last..tukar formula :
a = b*c*d;
(https://repl.it/@Nurul_HudaHuda/areavolume)
Ok...senang citer macam nilah..sebab ada yang tanya kalau nak guna formula physics, angle dan lain-lain tu macam mana?
kalau ada 3 abjad a, b and c..tu maksudnya ada satu operasi dan dua number
kalau 4 abjad a,b,c dan d....tu maknanya dua operasi dan 3 nombor...
Saya start dengan area dulu :
cube (a = (Math.pow(b,3)))
rectangle (a = b*c*d)
faham x setakat ni..
Ok...senang citer macam nilah..sebab ada yang tanya kalau nak guna formula physics, angle dan lain-lain tu macam mana?
kalau ada 3 abjad a, b and c..tu maksudnya ada satu operasi dan dua number
kalau 4 abjad a,b,c dan d....tu maknanya dua operasi dan 3 nombor...
Saya start dengan area dulu :
* kalau ada huruf d maknanya kena buat macam style volume tadi..volume :
square (a = (Math.pow(b,2)))
*maksudnya cuma ada a dan b je.. c kena delete
rectangle (a = b*c)
triangle (a = 0.5*b*c)
circle (a = b*(Math.pow(c,2)))
*b ni nnti tulislah use 3.14 sbb b ni radius
trapezium (a = 0.5*(b+c)*d)
parallelogram(a = b*c)
cube (a = (Math.pow(b,3)))
rectangle (a = b*c*d)
faham x setakat ni..
Comments
Post a Comment