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

programnyakok eror semua tuh,,,,,,,,,
Nggak juga bang… saya coba dan brehasil kok. Coba di ketik ulg, jgn langsung di copas!
error gan…
error smua gannnn
Thankss ya… programmnya jalan