Jumlah Data
package jumlahdata;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int a,i;
Scanner input=new Scanner(System.in);
System.out.print("masukan data="); a=input.nextInt();
for (i=1; i<=a; i++)
{
System.out.println("NPM");
System.out.println("Nama");
System.out.println("Jurusan\n");
}
}
}
Looping metode input
package loopingmetodearray;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int in,dy;
System.out.print("Masukan nilai awal="); in=input.nextInt();
System.out.print("Masukan nilai akhir="); dy=input.nextInt();
for (int i=in; i<dy; i++)
System.out.println(i);
}
}
Tidak ada komentar:
Posting Komentar