0

How to print table of a number using buffered reader?

29th Apr 2017, 9:47 AM
Kishan Mittal
2 Réponses
0
sorry but buffered reader is used to input a no.
29th Apr 2017, 10:00 AM
Kishan Mittal
0
import java.io.*; public class MultiplicationTable { private static PrintStream p=System.out; public static BufferedReader q= new BufferedReader (new InputStreamReader (System.in)); public static void main(String []args)throws IOException{ int n,x,y,z; p.println("MULTIPLICATION TABLE"); do{ p.print("Enter a number (2-12): "); String num=q.readLine(); n=Integer.parseInt(num); } while(n<=1||n>=13); for (x=1; x<=n; x++){ for (y=1; y<=n; y++){ z=x*y; p.print(z +" "); } p.println(); } } }
29th Apr 2017, 10:09 AM
James
James - avatar