sexta-feira, 6 de fevereiro de 2009

CODIFICANDO UM APLICATIVO EMPRESARIAL REAL

Colocaremos todas as suas novas aplicações em Java em uso como algo prático. Precisamos de uma classe com método main(), um tipo int e uma variável String, um loop while e teste IF. Mais alguns retoques e você estará construindo esse back-end empresarial sem demora. Mas antes examinará o código dessa rotina e pensará por um instante em você codificaria esse grande clássico, “99 garrafas de cervejas”.
OBS: Há erros tente encontrar o ERRO na rotina !

public class BeerSong {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

int beerNum = 99;

String word = "bottles";

while (beerNum > 0) {

if (beerNum == 1){
word = "bottle"; // no singular, uma Garrafa
}

System.out.println(beerNum + " " + word + " of beer on the wall") ;
System.out.println("Take one down.");
System.out.println("Pass it around");

if (beerNum > 0){
System.out.println(beerNum + " " + word + " of beer on the wall");

}else{
System.out.println("No more bottles of beer on the wall");
}

}
}

Nenhum comentário:

Postar um comentário