ตัวอย่างโค้ด สำหรับการเขียนโปรแกรมแสดงสูตรคูณแม่ 2 – 13 โดยใช้ภาษาจาวา (Java)
ตัวอย่างโค้ด
//----------------------------------------------------------
// Author : THAI OPEN CODE
// Author URI: https://www.thaiopencode.com
// Facebook : https://www.facebook.com/ThaiOpenCode
//----------------------------------------------------------
public class Multiplication {
public static void main(String[] args){
for(int i=1; i<=12; i++){
int n = 2;
for(int j=1; j<=6; j++){
System.out.printf("%5dx%2d=%3d", n, i, n*i);
n++;
}
System.out.println();
}
System.out.print("\n\n");
for(int i=1; i<=12; i++){
int n = 8;
for(int j=1; j<=6; j++){
System.out.printf("%5dx%2d=%3d", n, i, n*i);
n++;
}
System.out.println();
}
}
}
แสดงผล
