You are on page 1of 3

public class program_while {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 1;
while (a <=5){
System.out.println(a);
a++;

}
}

import java.util.Scanner;
public class coba1 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int alas,tinggi;
double luas;
System.out.println("Masukkan Panjang Alas =");
alas = input.nextInt();
while (alas <=0){
System.out.println("Masukkan Panjang Alas=");
alas=input.nextInt();
}
System.out.println("Masukkan Tinggi =");
tinggi = input.nextInt();
while (alas <=0){
System.out.println("Masukkan Tinggi=");
alas=input.nextInt();
}
luas=alas*tinggi*0.5;
System.out.println("Luas Segitiga ="+ luas);
}

}
import java.util.Scanner;
public class gunung {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int r,s,n=1;
System.out.print("banyak bukit=");
Scanner bput= new Scanner (System.in);
r=bput.nextInt();

System.out.print("tinggi bukit = ");


Scanner tput= new Scanner (System.in);
s=tput.nextInt();
while (n <= r){
int i=1;
while(i <5){
int j=1;
while(j <= i){
System.out.print("+");
j++;
}
System.out.println();
i++;
}
i=1;
while(i <= 5){
int j= i;
while(j <= 5){
System.out.print("+");
j++;

}
System.out.println();
i++;
}
n++;}
}

public class bil_genap {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i= 2;
System.out.println("MENCETAK BILANGAN GENAP");
while (i <=100){
System.out.println(i);
i=i+2;
}
}
}

You might also like