Machine Problem:
Create a Multiplication Table that ranges from 2 to 12 only.
Output:
Source Code:
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();
}
}
}
0 comments:
Post a Comment