Tugas Looping (input)
While & Do While
#WHILE
CODDING:
/**
* @(#)while1.java
*
*
* @author
* @version 1.00 2015/4/6
*/
import java.util.Scanner;
public class while1 {
public static void main (String[] args) {
System.out.println("Looping While");
System.out.println("---------------------");
Scanner masukkan = new Scanner (System.in);
System.out.print ("Masukkan Jumlah = ");
int jumlah = masukkan.nextInt();
System.out.println("---------------------");
int i=1;
while (i<=jumlah) {
System.out.println(i+" STMIK");
i++;
}
}
}
OUTPUT :
#DO.........WHILE
CODDING :
/**
* @(#)dowhile1.java
*
*
* @author
* @version 1.00 2015/4/6
*/
import java.util.Scanner;
public class dowhile1 {
public static void main (String[] args) {
System.out.println("Looping Do------While");
System.out.println("---------------------");
Scanner masukkan = new Scanner (System.in);
System.out.print ("Masukkan Jumlah = ");
int jumlah = masukkan.nextInt();
System.out.println("---------------------");
int i=1;
do
{
System.out.println(i+" STMIK");
i++;
}
while (i<=jumlah) ;
}
}
OUTPUT :
Tidak ada komentar:
Posting Komentar