loop

public void beep()

public boolean checkAlarm()

public void alarm(){
	boolean on = checkAlarm();
	while(on){
		beep();
		on = checkAlarm();
	}

}
String googol = "1";
int len = googol.length();
while(len < 101){
	googol = googol + "0";
	len = googol.length();
}

while loop

public int keepRolling(){
	int dice1 = rollDice();
	int dice2 = rollDice();
	int count = 1;
	while(!(dice1 == dice2)){
		dice1 = rollDice();
		dice2 = rollDice();
		count = count + 1;
	}
	return count;
}
public void raiseAlarm(int numOfWarnings){
	int i = 1;
	while(i <= numOfWarnings){
		System.out.println("warning");
		i = i + 1;
	}
}
public void raiseAlarm(int numOfWarnings){
	for (int i = 1; i <= numOfWarnings; i++){
		System.out.println("Warning");
	}
}

pyramid

public int countBlocks(int levels){
	int sum = 0;
	for(int i = 1; i <= levels; i++)
	{
		sum = sum + i * i; 
	}
    return sum;
}
public int martingale(){
	int money = 1000;
	int target = 1200;
	int bet = 10;
	while(money>bet){
		boolean win = play();
		if(win){
			money += bet;
			bet = 10;
		}
		else {
			money -= bet;
			bet *= 2;
		}
	}
	return money;
}