Herzlich Willkommen

Live processing contents

Tuesday, February 1, 2011

iseng pemanasan otak yang belet

 GATEL
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package latihanawal;
import javax.swing.*;

public class Main {
public static final double PHI= 3.14;

static void test (){
    Main t = new Main();
    double radius;
    }

    public static void main(String[] args) {
        // TODO code application logic here
    String input = JOptionPane.showInputDialog("masukkan radius : ");
    double radius = Double.parseDouble(input);
    System.out.println("Kel Lingkaran jari-jari   "+radius+"adalah  "+Main.calcCircumference(radius));
    System.out.println("Luas Lingkaran jari-jari  "+radius+"adalah  "+Main.calcArea(radius));
        }
static double calcCircumference (double r){
    return(2*PHI*r);
    }
static double calcArea (double r){
    return (PHI*r*r);
    }
}

--------------------------------------------------------------------------------------

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package latihanawal;

/**
 *
 * @author TRACER
 */
public class lat1 {

    private String name = "";
    private double density = 0;

    public lat1() {
    }

    public lat1(String name, double density) {
        this.name = name;
        this.density = density;
    }

    public double getMass(double volume) {
        return density * volume;
    }
    public double getdensity(){
        return density;
    }
    public double getvolume(double mass){
        return mass/density;
    }
    @Override
    public String toString(){
     String str = "benda"+"\n"+
             "Nama benda = "+name+"\n"+
             "Massa jenis = "+density+"\n";
     return str;
    }
    static void test(){
        lat1 x = new lat1("Aluminum",2.7);
        System.out.println(x);
    }
    public static void main(String [] args){
        test();
    }
}

--------------------------------------------------------------------------------------
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package latihanawal;
import javax.swing.*;
/**
 *
 * @author TRACER
 */
public class lat2 {
public static void main (String [] args){
    String input = JOptionPane.showInputDialog("Baraha tinggi menara EIFEL ?");
    double height = Double.parseDouble(input);
    System.out.println("Tingginya = "+height);
    System.exit(0);

}
}
--------------------------------------------------------------------------------------
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package latihanawal;
import java.text.*;
import java.util.*;
import javax.swing.JOptionPane;
/**
 *
 * @author TRACER
 */
public class lat3 {
      double n;
public static void main(String [] args){

    String input = JOptionPane.showInputDialog("masukkan n : ");
    double n = Double.parseDouble(input);

    NumberFormat number =
    NumberFormat.getNumberInstance(Locale.GERMANY);

    NumberFormat currency =
    NumberFormat.getCurrencyInstance(Locale.GERMANY);

    NumberFormat percent =
    NumberFormat.getPercentInstance(Locale.GERMANY);

    String numberStr = number.format(n);
    String currStr = currency.format(n);
    String percentStr = percent.format(n);

    System.out.println("double 1000.0/3.0 berformat number    "   + numberStr);
     System.out.println("double 1000.0/3.0 berformat current   "   + currStr);
      System.out.println("double 1000.0/3.0 berformat percent   "   + percentStr);
}
}
--------------------------------------------------------------------------------------
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package latihanawal;
import javax.swing.*;
/**
 *
 * @author TRACER
 */
public class lat4 {
    static void test (){
        double sisi;
        lat4 f = new lat4 ();
    }



public static void main(String []args){
    String input = JOptionPane.showInputDialog("masukkan sisi");
    double sisi = Double.parseDouble(input);
    System.out.println(" Keliling kubus bersisi "+ sisi + "   adalah "+ calcCircumference(sisi));
     System.out.println(" luas kubus bersisi "+ sisi + "    adalah "+ calcArea(sisi));
      System.out.println(" volume kubus bersisi "+ sisi + "    adalah "+ calcVolume(sisi));
}
static double calcCircumference(double s){
        return (12*s);
    }
static double calcArea(double s){
        return (6*s*s);
    }
static double calcVolume (double s){
        return (s*s*s);
    }
}

--------------------------------------------------------------------------------------

`````````````````````iseng````````````````````````````````````````````````````````````iseng``````````

No comments:

Post a Comment