caxinaswin Posted April 23, 2015 at 07:21 PM Report Share #581748 Posted April 23, 2015 at 07:21 PM (edited) tenho o seguinte problema: Implemente o metodo, com a seguinte assinatura static void tabuada(int n), que dado um numero inteiro, imprima a respetiva tabuada. Utilize o metodo num programa que peca numero inteiros ao utilizador e imprima as respectivas tabuadas. O programa deve terminar quando for inserido um zero. fiz desta forma: Scanner in = new Scanner(System.in); int numero = 1; while(numero != 0) { System.out.print("introduza a tabuada que pretende: "); numero = in.nextInt(); tabuada(numero); } public static void tabuada(int n) { for(int i = 1;i<=10;i++) { System.out.println(n + "*" + i + "=" + (n*i)); } } A minha questão prende -se com o 0, eu não queria imprimir essa tabuada como faço????:S Edited April 23, 2015 at 08:55 PM by apocsantos tag code + geshi Link to comment Share on other sites More sharing options...
Solution FQueiros Posted April 24, 2015 at 05:10 PM Solution Report Share #581808 Posted April 24, 2015 at 05:10 PM (edited) o mais simples para usares é colocar um if(numero > 0){ tabuada(numero); } assim só fazes a impressão com numero maior que 0 Edited April 24, 2015 at 06:14 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
caxinaswin Posted April 25, 2015 at 11:37 AM Author Report Share #581831 Posted April 25, 2015 at 11:37 AM Realmente a resposta era fácil, ás vezes quem programa preocupa-se mais com as respostas mais dificeis obrigado (: Link to comment Share on other sites More sharing options...
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