Lab Loop
/*
Kusumoto Lab1 Programming
http://kusumoto.co
*/
import java.util.Scanner;
class Lab1 {
public static void main(String[] args) {
//announce variable
int loop;
int loop_start;
int fac_start;
int fac;
int time;
int time_temp = 1;
int time_temp1 = 0;
int temp = 0;
//input method setup
Scanner loop1 = new Scanner (System.in);
Scanner fac1 = new Scanner (System.in);
//input loop2
System.out.print("Enter Number Loop :: ");
loop = loop1.nextInt();
//loop construction
for (loop_start = 1;loop_start <= loop; loop_start++) {
//factorial input
System.out.print("Enter factorial :: ");
fac = fac1.nextInt();
//factorial construction
for (fac_start = 1;fac_start <= fac;fac_start++) {
System.out.print("Times ="+fac_start);
time_temp = fac_start * time_temp;
System.out.println(" Sum = "+time_temp);
time_temp1 = time_temp+time_temp1;
}
//Overrall Construction
System.out.println("Total : "+time_temp1);
System.out.println("==============================");
temp = time_temp1+temp;
time_temp1 = 0;
time_temp = 1;
}
//Show Overrall
System.out.println("Overrall : "+temp);
}
} |
/*
Kusumoto Lab1 Programming
http://kusumoto.co
*/
import java.util.Scanner;
class Lab1 {
public static void main(String[] args) {
//announce variable
int loop;
int loop_start;
int fac_start;
int fac;
int time;
int time_temp = 1;
int time_temp1 = 0;
int temp = 0;
//input method setup
Scanner loop1 = new Scanner (System.in);
Scanner fac1 = new Scanner (System.in);
//input loop2
System.out.print("Enter Number Loop :: ");
loop = loop1.nextInt();
//loop construction
for (loop_start = 1;loop_start <= loop; loop_start++) {
//factorial input
System.out.print("Enter factorial :: ");
fac = fac1.nextInt();
//factorial construction
for (fac_start = 1;fac_start <= fac;fac_start++) {
System.out.print("Times ="+fac_start);
time_temp = fac_start * time_temp;
System.out.println(" Sum = "+time_temp);
time_temp1 = time_temp+time_temp1;
}
//Overrall Construction
System.out.println("Total : "+time_temp1);
System.out.println("==============================");
temp = time_temp1+temp;
time_temp1 = 0;
time_temp = 1;
}
//Show Overrall
System.out.println("Overrall : "+temp);
}
}
สูตรคูณ
/*
Kusumoto Lab2 Programming
http://kusumoto.co
*/
import java.util.Scanner;
class lab2 {
public static void main(String[] args) {
//announce variable
int master;
int slave;
int temp;
//input setup
Scanner master1 = new Scanner (System.in);
Scanner slave1 = new Scanner (System.in);
//input data
System.out.print("Enter Number 1 : ");
master = master1.nextInt();
System.out.print("Enter Number 2 : ");
slave = slave1.nextInt();
System.out.println("===============================");
//loop construction
for (temp = 1;temp<=slave;temp++) {
System.out.println(master+" x "+temp+" = "+master*temp);
}
System.out.println("===============================");
}
} |
/*
Kusumoto Lab2 Programming
http://kusumoto.co
*/
import java.util.Scanner;
class lab2 {
public static void main(String[] args) {
//announce variable
int master;
int slave;
int temp;
//input setup
Scanner master1 = new Scanner (System.in);
Scanner slave1 = new Scanner (System.in);
//input data
System.out.print("Enter Number 1 : ");
master = master1.nextInt();
System.out.print("Enter Number 2 : ");
slave = slave1.nextInt();
System.out.println("===============================");
//loop construction
for (temp = 1;temp<=slave;temp++) {
System.out.println(master+" x "+temp+" = "+master*temp);
}
System.out.println("===============================");
}
}