[RESOLVIDO]Dúvida - Famoso exercicio de adivinhação
17/02/2012
0
package JogoAdivinha; import javax.swing.JOptionPane; public class Jogo { public static void main(String[] args) { String nome ; int numTentativas ; int randon = (int)(1+Math.random()*100); int[] jogadas = new int[20]; nome = JOptionPane.showInputDialog(null,"Olá,qual o seu nome?"); JOptionPane.showMessageDialog(null,"Agora estou pensando em um número...Pronto!Tente adivinhar!"); numTentativas = Integer.parseInt(JOptionPane.showInputDialog(null,"Qual número você acha que é?")); for(int i = 0; i < 21; i++) while(numTentativas != randon && numTentativas < 21) { numTentativas = Integer.parseInt(JOptionPane.showInputDialog(null,"Tente de novo "+nome+ ".")); if (numTentativas < randon) JOptionPane.showMessageDialog(null,"Tente um numero maior " +nome+"."); else if (numTentativas > randon) JOptionPane.showMessageDialog(null,"Tente um numero menor " +nome+"."); } if (numTentativas == randon) JOptionPane.showMessageDialog(null,"PARABÉNS "+nome+" !!"); JOptionPane.showMessageDialog(null,"Você acertou na " +jogadas); else (numTentativas < 21) JOptionPane.showMessageDialog(null,"Fim de jogo,acabaram as tentativas."); } }
Kleber Bogo
Posts
05/03/2012
Lucas Iorio
while(continua){ tentativas = Integer.parseInt(JOptionPane.showInputDialog(null,"Vamos começar,qual o número?")); chutes = 1 ; tentativas = 1; randon = (int)(1+Math.random()*100); while(tentativas != randon && chutes < 10)
tentativas = 1;
tentativas = Integer.parseInt(JOptionPane.showInputDialog(null,"Vamos começar,qual o número?"));
05/03/2012
Douglas Eric