Pertemuan Ke-3: Operator #1

Senin, 28 Mei 2012


public class operator1 {


    public static void main(String[] args)
    {
    System.out.println("Operasi Aritmatika Pada tipe integer");
    int a=7+4;
    int b=a-4;
    int c=a*b;
    int d=c/3;
    int e=-a;
   
    System.out.println("Nilai a: "+a);
    System.out.println("Nilai b: "+b);
    System.out.println("Nilai c: "+c);
    System.out.println("Nilai d: "+d);
    System.out.println("Nilai e: "+e);
    System.out.println();
   
    System.out.println("Operasi Aritmatika Pada tipe floating-point");
    double fa=7+4;
    double fb=fa-4;
    double fc=fa*fb;
    double fd=fc/3;
    double fe=-a;
   
    System.out.println("Nilai fa; "+fa);
    System.out.println("Nilai fb; "+fb);
    System.out.println("Nilai fc; "+fc);
    System.out.println("Nilai fd; "+fd);
    System.out.println("Nilai fe; "+fe);
   
    }
}


Hasil dari skrip tersebut adalah:





0 komentar: