Home > Array, Java Programming > Mencetak hari dalam seminggu dengan Array

Mencetak hari dalam seminggu dengan Array


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++;
}
}
}

Dengan menggunakan Do While

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

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

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

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

Dengan menggunakan For

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

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

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

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

Download Source Code : http://www.ziddu.com/download/7961139/ArrayHariSeminggu.zip.html

Categories: Array, Java Programming Tags:
  1. hack
    March 15, 2010 at 4:16 am | #1

    programnyakok eror semua tuh,,,,,,,,,

    • Alfan F
      July 2, 2010 at 6:32 am | #2

      Nggak juga bang… saya coba dan brehasil kok. Coba di ketik ulg, jgn langsung di copas!

  2. masBReELL
    October 31, 2011 at 1:31 pm | #3

    error gan…

  3. asnimarlis
    May 18, 2012 at 2:15 am | #4

    error smua gannnn

  4. asnimarlis
    May 18, 2012 at 3:13 am | #5

    Thankss ya… programmnya jalan

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.