Menghitung Integral di Java

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

package integral;

/**
*
* @author Angga
*/
public class integral {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println(“Program Menghitung Integral By Mas ANGGA”);
System.out.println(“****************************************”);
System.out.println(“Hitunglah INTEGRAL dari (2X^3+6X^2-2X+9)”);

System.out.println(“RUMUS : aX^n dx –> a/n+1 X^n+1 +C”);
System.out.println(“\t”+”a dx –> aX +C”);
System.out.println(“Jawab :”);

int a,b,c,d,pangkat1,pangkat2,pangkat3,pangkat4;
a=2;
b=6;
c=-2;
d=9;
pangkat1=3;
pangkat2=2;
pangkat3=1;
pangkat4=0;

System.out.println(“Jadi Integralnya Adalah :”);
System.out.print(a+”/”+ ++pangkat1 +”X^”+ pangkat1++);
System.out.print(“+”+b/++pangkat2 +”X^”+ pangkat2++);
System.out.print(c/++pangkat3 +”X^”+ pangkat3++);
System.out.println(“+”+d+”X +C”+”\n”); //”a dx –> aX +C”

}

}

Insertion Sort di Java

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

package insertionsortnew;

/**
*
* @author KIREINA
*/
public class insertionSortNew {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int array[] = {4,5,1,8,6,2,7,20,12,24,14,17};
int a;
int b;

System.out.println(“Data acak :”);
for(int index=0; index<array.length; index++) {
System.out.print(array[index]+" ");
}
System.out.println("");

// sorting
for(a=1; a0 && array[b-1] >= temp) {
array[b] = array[b-1];
b–;
}
array[b] = temp;
}

System.out.println(“Setelah Sorting :”);
for(int index=0; index<array.length; index++) {
System.out.print(array[index] +" ");
}
System.out.println("");
}
}

Insertion Sort Menggunakan Method di Java

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

package insertionsort;

/**
*
* @author KIREINA
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic
int i;
int data[] = {-6,-9,1,33,25,11,50,100,200,156};
System.out.println(” Sorting (INSERTION) Oleh :”);
System.out.println(” NAMA : ANGGA ARI WIJAYA”);
System.out.println(” N.I.M : 102410101070″+”\n”);
System.out.println(“Data Sebelum sorting “);

for(i = 0; i < data.length; i++)
System.out.print( data[i]+" ");
System.out.println();

insertion_srt(data, data.length);
System.out.println("Data setelah disorting:");
for(i = 0; i <data.length; i++)
System.out.print(data[i]+" ");
System.out.println();
}

public static void insertion_srt(int data[], int k){
for (int i = 1; i 0) && (data[j-1] > B)){
data[j] = data[j-1];
j–;
}
data[j] = B;
}
}
}

Try Catch Exception di Java

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

package ifelsename;

/**
*
* @author komp19
*/
public class ifElseName {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
char firstInitial = ‘a’;
System.out.println(“Masukkan huruf awal nama Anda :”);
try {
firstInitial = (char)System.in.read();
} catch (Exception e){
System.out.println(“Error: ” + e.toString());
}

if(firstInitial == ‘a’)
System.out.println(“Nama anda pasti Asep!”);
else if(firstInitial == ‘b’)
System.out.println(“Nama anda pasti Brodin!”);
else if(firstInitial == ‘c’)
System.out.println(“Nama anda pasti Cecep!”);
else
System.out.println(“Nama anda tidak dikenal!”);

}
}

Mengidentifikasi Karakter di Java

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

package identifikasikarakter;

/**
*
* @author Angga
*/
public class identifikasiKarakter {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
char karakter = ‘0’;
System.out.println(“Masukkan sebuah karakter :”);
try {
karakter = (char)System.in.read();
}
catch (Exception e){
}
if (karakter >= ‘0’ && karakter = ‘a’ && karakter = ‘A’ && karakter <= 'Z')
System.out.println("\""+karakter+"\""+" termasuk Huruf Besar");
else
System.out.println("\""+karakter+"\""+" termasuk Karakter Khusus/Operator");
System.out.println("By Mas ANGGA");

}

}

Menghitung Luas Segitiga di Java

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

package hitungluassegitiga;

/**
*
* @author Jet
*/
public class HitungLuasSegitiga {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println (“PROGRAM HITUNG LUAS SEGITIGA”);
System.out.println (“Alas = 15,5 Cm”);
System.out.println (“Tinggi = 20 Cm”+”\n”);
System.out.println (“RUMUS : 1/2 x Alas x Tinggi”);
System.out.println (“\t”+”1/2 x 15,5 x 20″+”\n”);
System.out.println (“HASIL :” + 0.5*15.5*20+”\n”);
System.out.println (“Created By : Mas ANGGA”);
}

}

Hello World! Java

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

package helloworldapp;

/**
*
* @author komp18
*/
public class HelloWorldApp {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println(“Hello World!”);
}

}

Mencetak Array Menggunakan While – Do di Java

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

package haridalamsemingguwhiledo;

/**
*
* @author komp34
*/
public class hariDalamSemingguWhileDo {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String[] hari={“Monday”, “Tuesday”, “Wednesday”, “Thusday”, “Friday”, “Saturday”, “Sunday”};
System.out.println(“Nama Hari dalam seminggu : “);
int i = 0;
while(i<hari.length){
System.out.println(i+". "+hari[i]);
i++;
}
}
}