๋ฐ์ํ
์ค์ต) ๊ตฌ๊ตฌ๋จ์ ๋ง๋ค์ด๋ณด์์ค.
์กฐ๊ฑด : ๋ฉ์๋๋ก ํธ์ถํ๊ธฐ |
โ
<๋ด๊ฐ ํ ๊ฒ>
โ
ProgTest1.java
package quiz;
import java.util.Scanner;
public class ProgTest1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("๋ช๋จ์ ๋ณด์๊ฒ ์ต๋๊น?");
int n = sc.nextInt();
int dan, times;
System.out.println(n + "๋จ :");
for (dan = n; dan <= n; dan++) {
for (times = 1; times <= 9; times++) {
System.out.print(n + "*" + times + "=" + n * times + " ");
}
}
}
}
<๊ฒฐ๊ณผ๊ฐ>
-์ผ๋จ ๋ฉ์๋๋ก ํธ์ถํ๋๊ฑฐ ๋ง๊ณ ์ด๋ ๊ฒ ๋ง๋ค์ด๋ดค๋ค
๋ฉ์๋๋ก ๋ง๋๋๊ฑด ์คํจ!
โ
โ
ProgTest2.java
package quiz;
import java.util.Scanner;
public class ProgTest2 {
public int cVar = 0;
String[] iStr = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
double iDouble;
boolean iBool = false;
char iChar = 'a';
String getGugugan(int dan) {
String str = dan + "๋จ:\n";
for (int i = 1; i < 10; i++) {
str += dan + "*" + i + "=" + (dan * i) + "\t";
}
return str;
}
public static void main(String[] args) {
ProgTest2 pt2 = new ProgTest2();
Scanner sc = new Scanner(System.in);
System.out.print("๋ช๋จ์ ๋ณด์๊ฒ ์ต๋๊น? ");
int dan = sc.nextInt();
System.out.println(pt2.getGugugan(dan));
}
}
<๊ฒฐ๊ณผ๊ฐ>
-๋ฉ์๋๋ก ์ ์ํด์ ํธ์ถํ๋๊ฒ ์ข ์ด๋ ค์ ๋ค (๋งจ๋ get, set ์ด๋ฐ๊ฑฐ๋ง ํด์ ๊ทธ๋ฐ๋ฏ)
๋ฐ์ํ
'Java' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java-๊ธฐ์ด] ์ค์ต (์ฃผ๋ฌธ๋ฒํธ, ์ํ์ด๋ฆ, ์ํ๊ฐ๊ฒฉ, ๊ฐฏ์) (0) | 2021.02.24 |
---|---|
[Java-๊ธฐ์ด] ์ค์ต (๋ฉค๋ฒ ํธ์ถ) (0) | 2021.02.24 |
[Java-๊ธฐ์ด] ์ค์ต (๋ก๋ ์ถ์ฒจ ๋ฒํธ) (0) | 2021.02.24 |
[Java-๊ธฐ์ด] ์๊ณ ๋ฆฌ์ฆ ์ค์ต (๋ง๋ฐฉ์ง) (0) | 2021.02.24 |
[Java-๊ธฐ์ด] ์๊ณ ๋ฆฌ์ฆ ์ค์ต (๋ฒ๋ธ์ ๋ ฌ) (0) | 2021.02.24 |
๋๊ธ