본문 바로가기
JAVA/[JAVA]codeUp 기초100제 자바

[JAVA]codeUp 기초100제 자바 1001~1008번

by oncerun 2020. 2. 25.
반응형

1001.

C/C++언어에서 가장 기본적인 명령이 출력문이다.
printf()를 이용해 다음 단어를 출력하시오.

Hello

public class Main {

	public static void main(String[] args) {
		    System.out.print("Hello");

  }
}

 

1002.

이번에는 공백()을 포함한 문장을 출력한다.
다음 문장을 출력해보자.
(대소문자에 주의한다.)
Hello World

public class Main {

	public static void main(String[] args) {
		System.out.print("Hello World");
	}

}
	

1003.

이번에는 줄을 바꿔 출력하는 출력문을 연습해보자.
다음과 같이 줄을 바꿔 출력해야 한다.

Hello
World
(두 줄에 걸쳐 줄을 바꿔 출력)

public class Main {

	public static void main(String[] args) {
	System.out.print("Hello");
    System.out.print("World");
	}

}
	

1004.

이번에는 작은 따옴표(single quotation mark)가 들어있는
특수한 형태의 출력문에 대한 연습을 해보자.

다음 문장을 출력하시오.

'Hello'

public class Main {

	public static void main(String[] args) {
		    System.out.print("\'Hello World\'");

  }
}

 

1005.

이번에는 큰따옴표(double quotation mark)가 포함된 출력문을 연습해보자.

다음 문장을 출력하시오.

"Hello World"
(단, 큰따옴표도 함께 출력한다.)

public class Main {

	public static void main(String[] args) {
		    System.out.print("\"Hello World\"");

  }
}

 

 

1006.

이번에는 특수문자 출력에 도전하자!!

다음 문장을 출력하시오.

"!@#$%^&*()"
(단, 큰따옴표도 함께 출력한다.)

public class Main {

	public static void main(String[] args) {
		    System.out.print("\"!@#$%^&*()\"");

  }
}

1007.

윈도우 운영체제의 파일 경로를 출력하는 연습을 해보자.
 
파일 경로에는 특수문자들이 포함된다.

다음 경로를 출력하시오.

"C:\Download\hello.cpp"
(단, 큰따옴표도 함께 출력한다.)

public class Main {

	public static void main(String[] args) {
		
		System.out.print("\"C:\\Download\\hello.cpp\"");
  }
}

 

1008.

이번에는 특수문자를 출력하는 연습을 해보자.

키보드로 입력할 수 없는 다음 모양을 출력해보자.
(** 참고 : 운영체제의 문자 시스템에 따라 아래와 같은 모양이 출력되지 않을 수 있다.)

┌┬┐
├┼┤
└┴┘

public class Main {

	public static void main(String[] args) {
		System.out.print("\u250C\u252C\u2510\n");
		System.out.print("\u251C\u253C\u2524\n");
		System.out.print("\u2514\u2534\u2518\n");
	}

}
	

 

 

출처 https://codeup.kr/index.php

반응형

댓글