문제

quiz

  • 파운드 단위 변환




코드

Conversion.java

package pack_CusCls03;

import java.util.Scanner;

public class Conversion {

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		System.out.print("Kg을 입력해주세요 : ");
		double kilo = scanner.nextDouble();
		scanner.close();
		
		Pound pound = new Pound(kilo);
		
		pound.mtdChange();

	}

}

Pound.java

package pack_CusCls03;

public class Pound {
	
	private double kilo;

	public Pound(double kilo) {
		this.kilo = kilo;
	}
	
	public void mtdChange() {
		
		double res = kilo * 2.2;
		
		System.out.printf("파운드(lb) : %.1f lb", res);
		
		
	}

}


결과

quiz

Leave a comment