728x90

연산식 3

[JAVA] 하나의 정수를 입력받아 1부터 입력받은 정수까지의 짝수를 차례대로 출력하는 프로그램

하나의 정수를 입력받아 1부터 입력받은 정수까지의 짝수를 차례대로 출력하는 프로그램 정수는 50이하 //긁지않은 개발자 public class Ex01 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0; do { System.out.print("1~50사이의 정수를 입력 : "); n = sc.nextInt(); } while (n 50); for (int i = 2; i

[JAVA] JAVA 산술연산자

JAVA 산술연산자 산술 연산자 : + - * / %(나머지) //긁지않은 개발자 public class Ex01 { public static void main(String[] args) { int i = 20, j = 10; int k = i + j; System.out.println(i + " + " + j + " = " + k); //20 + 10 = 30 k = i - j; System.out.println(i + " - " + j + " = " + k); // 20 - 10 = 10 k = i * j; System.out.println(i + " * " + j + " = " + k); // 20 * 10 = 200 k = i / j; System.out.println(i + " / " + j +..

[JAVA] JAVA 숫자 %로 나눠서 출력하기 (년,월,일 응용)

%(나머지) //긁지않은 개발자 public class Ex01 { public static void main(String[] args) { String birth1 = "123456"; int birth2 = 123456; System.out.println(birth2/10000); System.out.println(birth2/100%100); System.out.println(birth2%10000/100); System.out.println(birth2%100); System.out.println(birth1.substring(0,2)); System.out.println(birth1.substring(2,4)); System.out.println(birth1.substring(4)); } } 실..

728x90