Tim§id€ Posted December 24, 2012 at 01:53 PM Report #488264 Posted December 24, 2012 at 01:53 PM Boas, estou a fazer um programa e não estou a fazer como fazer o seguinte, por exemplo escrevo: BGT123 ou 123ABC se a primeira e a segunda letra é uma letra do abc e não um numero. String abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String c; podia fazer c.charAt(0)==abc.charAt(0....25) mas assim nunca mais sai de aqui! já tentei com for mas não estou a conseguir, Obrigado! ...º(>_<)º...
NunoDinis Posted December 24, 2012 at 02:56 PM Report #488270 Posted December 24, 2012 at 02:56 PM (edited) Podes comparar com a classe character. Character.isLetter(c.chartAt(posicao)); ou Character.isDigit(c.chartAt(posicao)); (Não pus em code porque está a dar erro) Edited December 24, 2012 at 02:59 PM by NunoDinis Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org
Tim§id€ Posted December 24, 2012 at 05:19 PM Author Report #488295 Posted December 24, 2012 at 05:19 PM Podes comparar com a classe character. Character.isLetter(c.chartAt(posicao)); ou Character.isDigit(c.chartAt(posicao)); (Não pus em code porque está a dar erro) Também não consigo com o character. ... ...º(>_<)º...
NunoDinis Posted December 24, 2012 at 05:46 PM Report #488302 Posted December 24, 2012 at 05:46 PM O que é que não consegues fazer afinal ? Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org
HappyHippyHippo Posted December 24, 2012 at 06:12 PM Report #488305 Posted December 24, 2012 at 06:12 PM e que tal apresentares o código que tens ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Tim§id€ Posted December 24, 2012 at 06:14 PM Author Report #488306 Posted December 24, 2012 at 06:14 PM (edited) e que tal apresentares o código que tens ? Scanner teclado = new Scanner(System.in); Scanner teclado = new Scanner(System.in); String matricula; //NN-NN-LL, NN-LL-NN, LL-NN-NN (L)-Letra [A,Z] (N) - Numero [0,9] System.out.println("Introduza uma matricula"); System.out.println("Formato→ NN-LL-NN onde (N→Numeros [0,9] e (L→Letras [A,Z])"); matricula = teclado.next(); if( Character.isDigit(matricula.charAt(3)) || Character.isDigit(matricula.charAt(4)) ) { System.out.println("NAo tem letras"); } } já da +/- agora falta fazer para o formato NN-LL-NN Edited December 24, 2012 at 06:21 PM by Tim§id€ ...º(>_<)º...
Tim§id€ Posted December 24, 2012 at 06:30 PM Author Report #488311 Posted December 24, 2012 at 06:30 PM já consegui.. Obrigado! ...º(>_<)º...
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