Archive

Posts Tagged ‘Array’

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]);
}
}
}

Contoh Program Array

December 31, 2009 Leave a comment

package SL275;

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

/**
*
* @author GW_SBY
*/
public class ArrayDemo {

public static void main(String[] args) {
int[] anArray; // declares an array of integers

anArray = new int[10]; // allocates memory for 10 integers

anArray[0] = 100; // initialize first element
anArray[1] = 200; // initialize second element
anArray[2] = 300; // etc.
anArray[3] = 400;
anArray[4] = 500;
anArray[5] = 600;
anArray[6] = 700;
anArray[7] = 800;
anArray[8] = 900;
anArray[9] = 1000;

System.out.println(“Element at index 0: ” + anArray[0]);
System.out.println(“Element at index 1: ” + anArray[1]);
System.out.println(“Element at index 2: ” + anArray[2]);
System.out.println(“Element at index 3: ” + anArray[3]);
System.out.println(“Element at index 4: ” + anArray[4]);
System.out.println(“Element at index 5: ” + anArray[5]);
System.out.println(“Element at index 6: ” + anArray[6]);
System.out.println(“Element at index 7: ” + anArray[7]);
System.out.println(“Element at index 8: ” + anArray[8]);
System.out.println(“Element at index 9: ” + anArray[9]);
}
}

Follow

Get every new post delivered to your Inbox.