XDwizzard Posted May 14, 2009 at 02:15 PM Report #264141 Posted May 14, 2009 at 02:15 PM tou-me a ? com um proble k o meu stor pos na aula de java para preencher um ficha do euromilhoes podem me ajudar eu tenho isto: import javax.swing.*; class alunos3 { public static void main (String[] args) throws java.io.IOException { String nalunos; String [] multivector = new String [20]; int [] numeros = new int [20]; int [] estrelas = new int [9]; int x=0; int grupo = 1; double aleat; int var; int y=0; System.out.println("N U M E R O S : "); System.out.println(" "); while (x<20){ nalunos=JOptionPane.showInputDialog("Introduza o nome do aluno: "); multivector [x]=nalunos; aleat = Math.random(); aleat=aleat*50+1; var = (int)aleat; numeros [x] = var; if (x==0 ||x==5 || x==10 || x==15 ) { System.out.println(" "); System.out.println("Grupo " + grupo); grupo++; } System.out.println(multivector[x] + " -> " + numeros [x]); x++; if (x==5 ||x==10 || x==15 || x==20 ) { System.out.println(" "); System.out.println(" "); System.out.println("E S T R E L A S :"); while (y<2){ aleat = Math.random(); aleat=aleat*9+1; var = (int)aleat; estrelas [y]=var; System.out.println(" * " + estrelas[y]); y++; } y=0; } } } }
M6 Posted May 14, 2009 at 02:31 PM Report #264146 Posted May 14, 2009 at 02:31 PM Podemos ajudar-te disseres qual é o teu problema! 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar."
felixs Posted May 14, 2009 at 02:52 PM Report #264156 Posted May 14, 2009 at 02:52 PM Ora bolas... e eu a pensar que alguém tinha implementado um algoritmo em Java que acertasse nos números do Euromilhões... 😄 @XDwizzard : Tens que ver o que se passa com o teu teclado, porque parece que os acentos não estão a funcionar. 😄
XDwizzard Posted May 14, 2009 at 03:51 PM Author Report #264166 Posted May 14, 2009 at 03:51 PM agora só não consigo fazer um controlo para ver se não da numeros iguais ficou assim: import javax.swing.*; class alunos3 { public static void main (String[] args) throws java.io.IOException { String nalunos; String [] multivector = new String [20]; int [] numeros = new int [20]; int [] estrelas = new int [2]; int x=0; int grupo = 0; double aleat; int var; int y=0; int ver; boolean existe=false; while (x<20){ nalunos=JOptionPane.showInputDialog("Introduza o nome do aluno: "); multivector [x]=nalunos; aleat = Math.random(); aleat=aleat*49+1; var = (int)aleat; numeros [x] = var; if (x==0 ||x==5 || x==10 || x==15 ) { grupo++; System.out.println("Grupo " + grupo); } System.out.println( multivector[x] + " -> " + numeros [x]); x++; if (x==5 ||x==10 || x==15 || x==20 ) { while (y<2){ aleat = Math.random(); aleat=aleat*9+1; var = (int)aleat; estrelas [y]=var; System.out.println( " * " + estrelas[y]); y++; } y=0; } } ver=Integer.parseInt(JOptionPane.showInputDialog("Introduza o nome do grupo que quer ver: ")); ver=(ver-1)*5; JOptionPane.showMessageDialog(null, numeros [ver] + " " + numeros [ver+1]+ " " + numeros [ver+2]+" " +numeros [ver+3]+" " +numeros [ver+4], "Grupo: " + grupo, JOptionPane.INFORMATION_MESSAGE); ver=Integer.parseInt(JOptionPane.showInputDialog("Digite um numero e verifique se esse numero existe: ")); x=0; while (x<20) { x++; if (ver==numeros [x]) { JOptionPane.showMessageDialog(null, ver + " existe!!", "ATENCAO " + grupo, JOptionPane.INFORMATION_MESSAGE); x=20; } else { if (x==19) JOptionPane.showMessageDialog(null, ver + " nao existe!!", "ATENCAO " + grupo, JOptionPane.INFORMATION_MESSAGE); x++; } } } }
M6 Posted May 15, 2009 at 09:30 AM Report #264308 Posted May 15, 2009 at 09:30 AM Para verificares se um número já saiu basta ires guardando os valores num array e a cada número que sai, seleccionar outro caso já esteva no array. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar."
XDwizzard Posted May 16, 2009 at 11:57 AM Author Report #264603 Posted May 16, 2009 at 11:57 AM 😁 yes concegui fazer obriigado pessoal
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now