Java Tutorial
In java programming, this program is used to display the product tables till the limit which will be specified by user input.
// Printing product tables till limit user is provided. import java.io.*; public class PrintTables { public static void main(String []args) throws IOException{ int i=1,j,limit; DataInputStream in= new DataInputStream(System.in); System.out.print("Enter product table limit: "); limit = Integer.parseInt(in.readLine()); // print tables while(i<=limit){ System.out.println("Table: "+i); System.out.println("------------"); j=1; while(j<=10){ System.out.println(i+"*"+j+"="+(i*j)); j++; } i++; System.out.println("-------------"); } } }Output:
D:\Java_Programs>javac PrintTables.java D:\Java_Programs>java PrintTables Enter product table limit: 3 Table: 1 ------------ 1*1=1 1*2=2 1*3=3 1*4=4 1*5=5 1*6=6 1*7=7 1*8=8 1*9=9 1*10=10 ------------- Table: 2 ------------ 2*1=2 2*2=4 2*3=6 2*4=8 2*5=10 2*6=12 2*7=14 2*8=16 2*9=18 2*10=20 ------------- Table: 3 ------------ 3*1=3 3*2=6 3*3=9 3*4=12 3*5=15 3*6=18 3*7=21 3*8=24 3*9=27 3*10=30 -------------
Java Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page