ZombieFake

Tabelline

Oct 25th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Tabelline {
  4.     private int input;
  5.    
  6.     public Tabelline()
  7.     {
  8.         Scanner In = new Scanner(System.in);
  9.         System.out.println("Di quale numero vuoi la tabellina (1-10)? ");
  10.         input = In.nextInt();
  11.         In.close();
  12.     }
  13.    
  14.     public boolean controlloInput()
  15.     {
  16.         if(input > 10 || input < 1)
  17.         {
  18.             System.out.println(("Numero non valido.\n"));
  19.             return false;
  20.         }
  21.         else
  22.         {
  23.             return true;
  24.         }
  25.     }
  26.    
  27.     public void calcolaTabellina()
  28.     {
  29.         for(int i=1; i <= 10; i++)
  30.         {
  31.             System.out.println(input + "x" + i + "=" + input*i + "\n");
  32.         }
  33.     }
  34. }
Add Comment
Please, Sign In to add comment