permulaan penggunaan kelas java dasar,
belajar pemrograman orientasi obyek dasar,
input dinamis, source code::
import java.io.*;
class bujursangkar{
double sisi;
}
class segitiga{
double alas;
double tinggi;
}
class jajargenjang{
double panjang;
double lebar;
}
public class Kuis4167 {
public static void main (String []args) throws IOException{
bujursangkar b = new bujursangkar();
segitiga s = new segitiga();
jajargenjang j = new jajargenjang();
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader (isr);
System.out.println("::keliling bujursangkar::");
System.out.print("sisi = ");
String si = input.readLine();
b.sisi = Double.parseDouble(si);
Double kelB=4*b.sisi;
System.out.println("keliling bujursangkar = "+kelB);
System.out.println("\n");
System.out.println("::luas segitiga::");
System.out.print("alas = ");
String a = input.readLine();
s.alas = Double.parseDouble(a);
System.out.print("tinggi = ");
String t = input.readLine();
s.tinggi = Double.parseDouble(t);
Double luasA=0.5*s.alas*s.tinggi;
System.out.println("luas segitiga = "+luasA);
System.out.println("\n");
System.out.println("::luas dan keliling jajargenjang::");
System.out.print("panjang = ");
String p = input.readLine();
j.panjang = Double.parseDouble(p);
System.out.print("sisimiring = ");
String l = input.readLine();
j.lebar = Double.parseDouble(l);
Double luasJ=j.panjang*j.lebar;
System.out.println("luas jajargenjang = "+luasJ);
Double kelJ=2*(j.panjang+j.lebar);
System.out.println("keliling jajargenjang = "+kelJ);
}
}
0 komentar:
Posting Komentar