Archive

Archive for the ‘Array’ Category

Mencari Nilai Terbesar Dengan JOptionPane

December 31, 2009 Leave a comment

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

import javax.swing.JOptionPane;

/**
*
* @author Arin
*/
public class MencariNilaiTerbesarJOptionPane {

public static void main(String[] args) {
int angka[] = new int[10];
int x = 0, z = 0;
String y = “”;

for (x = 0; x < 10; x++) {
y = JOptionPane.showInputDialog("Masukkan angka ke " + (x + 1) + ": ");
angka[x] = Integer.parseInt(y);
}
Read more…

Mencari Nilai Terbesar Dengan Buffered Reader

December 31, 2009 1 comment

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
*
* @author Arin
*/
public class MencariNilaiTerbesarBufferedReader {

public static void main(String[] args) {
int angka[] = new int[10];
int x = 0, z = 0;
String y = “”;

for (x = 0; x < 10; x++) {
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));

try {
System.out.print("Masukkan angka ke " + (x+1) + " : ");
y = dataIn.readLine();
angka[x] = Integer.parseInt(y);
} catch (IOException e) {
System.out.println("Error …." + e);
}
}
Read more…

Mencetak hari dalam seminggu dengan Array

December 31, 2009 5 comments

Dengan menggunakan While

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

/**
*
* @author Arin
*/
public class HariDalamSemingguWhileLoop {

public static void main(String[] args) {
String hari[] = {“Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”, “Sunday”};
int x = 0;

while (x < 7) {
System.out.println(hari[x]);
x++;
}
}
}

Read more…

Categories: Array, Java Programming Tags:

Contoh Program Buku Alamat dengan Array

December 31, 2009 Leave a comment

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

/**
*
* @author Arin
*/
public class BukuAlamat {

public static void main(String[] args) {
String[][] entry = {{“Florence”, “735-1234″, “Manila”},
{“Joyce”, “983-3333″, “Quezon City”},
{“Becca”, “456-3322″, “Manila”}};

int x = 0;

for (x = 0; x < 3; x++) {
System.out.println("Name : " + entry[x][0]);
System.out.println("Tel. # : " + entry[x][1]);
System.out.println("Address : " + entry[x][2]);
System.out.println("");
}
}
}

Download Source Code : http://www.ziddu.com/download/7961146/BukuAlamat.zip.html

Contoh Program Array (2)

December 31, 2009 Leave a comment

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

/**
*
* @author Arin
*/
public class ArraySample {

public static void main(String[] args) {
// int[] ages = new int[100];
// for (int i = 0; i < 100; i++) {
// System.out.println(ages[i]);
// }
int[] ages = new int[100];
for (int i = 0; i < ages.length; i++) {
System.out.println(ages[i]);
}
}
}

Follow

Get every new post delivered to your Inbox.