# 2์ฅ Lab ๋์ ๋ฌธ์ ํ์ด
60p_Lab ๋์ ๋ฌธ์ )
package chap02;
public class Lab_Advanced_60p {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("์๋ฐ๋ ๊ฐ์ฒด์งํฅ ํ๋ก๊ทธ๋๋ฐ ์ธ์ด์ด๋ค.");
System.out.println("์๋ฐ๋ ํ๋ซํผ ๋
๋ฆฝ์ฑ์ ๊ฐ์ถ๊ณ ์์ด, ํ ๋ฒ ์์ฑ๋ ์ฝ๋๋ฅผ ์ฌ๋ฌ ์ด์์ฒด์ ์์ ์คํํ ์ ์๋ค.");
System.out.println("์๋ฐ๋ ๋ฉํฐ์ค๋ ๋์ ๋ณ๋ ฌ์ฒ๋ฆฌ ๊ธฐ๋ฅ์ ์ ๊ณตํ ์ ์๋ค.");
}
}
73p_Lab ๋์ ๋ฌธ์ )
package chap02;
public class Lab_Advanced_73p {
public static void main(String[] args) {
// TODO Auto-generated method stub
double rocket_speed = 60000;
double distance = 40e12;
double secs;
secs = distance/rocket_speed;
double light_year = secs/(60.0*60.0*24.0*365.0);
System.out.println("์์ ์๊ฐ์ " + light_year + "๊ด๋
์
๋๋ค.");
}
}
88p_Lab ๋์ ๋ฌธ์ )
package chap02;
public class Lab_Advanced_88p {
public static void main(String[] args) {
// TODO Auto-generated method stub
double a = 1.0;
double b = -3.0;
double c = 2.0;
double disc = b * b - (4.0 * c * a);
double sqr = (double)Math.sqrt(disc);
double r1 = (-b + sqr) / 2.0 * a;
double r2 = (-b - sqr) / 2.0 * a;
System.out.println("์ฒซ ๋ฒ์งธ ๊ทผ: " + r1);
System.out.println("๋ ๋ฒ์งธ ๊ทผ: " + r2);
}
}
99p_Lab ๋์ ๋ฌธ์ )
package chap02;
import java.util.*;
public class Lab_Advanced_99p {
public static void main(String[] args) {
// TODO Auto-generated method stub
double w, h, area, perimeter;
Scanner input = new Scanner(System.in);
System.out.print("์ฌ๊ฐํ ๊ฐ๋ก: ");
w = input.nextInt();
System.out.print("์ฌ๊ฐํ ์ธ๋ก: ");
h = input.nextInt();
area = h * w;
perimeter = 2.0 * (w + h);
System.out.println("\ns" + "์ฌ๊ฐํ ๋์ด: " + area);
System.out.println("์ฌ๊ฐํ ๋๋ : " + perimeter);
System.out.println("์ฌ๊ฐํ์ ๋์ด๋ " + area + "์ด๊ณ , ๋๋ ๋ " + perimeter + "์ด๋ค.");
}
}
println() | print() | |
๊ณตํต์ | ์ฝ์ ์ถ๋ ฅ ๋ฉ์๋๋ก, ๊ดํธ๋ฅผ ํตํด ๋งค๊ฐ๋ณ์๋ฅผ ๋ฐ์ ์ถ๋ ฅ | |
์ฐจ์ด์ | ๊ฐ ์ถ๋ ฅ ํ ์๋์ผ๋ก ์ค๋ฐ๊ฟ | ์ค๋ฐ๊ฟ ์์ |