๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โœ’๏ธ Java Programming/์–ด์„œ์™€ Java๋Š” ์ฒ˜์Œ์ด์ง€!_2019 Ver

[์–ด์„œ์™€ Java๋Š” ์ฒ˜์Œ์ด์ง€!_2019 Ver] 2์žฅ Lab ๋„์ „๋ฌธ์ œ ํ’€์ด

by A Lim Han 2023. 4. 11.

# 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()
๊ณตํ†ต์  ์ฝ˜์†” ์ถœ๋ ฅ ๋ฉ”์†Œ๋“œ๋กœ, ๊ด„ํ˜ธ๋ฅผ ํ†ตํ•ด ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ฐ›์•„ ์ถœ๋ ฅ
์ฐจ์ด์  ๊ฐ’ ์ถœ๋ ฅ ํ›„ ์ž๋™์œผ๋กœ ์ค„๋ฐ”๊ฟˆ ์ค„๋ฐ”๊ฟˆ ์—†์Œ