DevTagebuch

원하는 진수변환과 값 입력 후 출력 (Scanner, If) 본문

Java/Do it

원하는 진수변환과 값 입력 후 출력 (Scanner, If)

yedevlife 2020. 4. 18. 02:38
public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		
		System.out.print("입력진수 결정 <1>10 <2>16 <3>8 ==>");
		int a=s.nextInt();
		
		System.out.print("Input Number");
		int b=s.nextInt();
		
		if (a==1)
			System.out.printf("10진수 ==> %d",b);
		if (a==2)
			System.out.printf("16진수 ==> %x",b);
		if (a==3)
			System.out.printf("8진수 ==> %o",b);
		
		s.close();

 

Comments