728x90 반응형 study/Java305 [Java] 29. Test1 풀이 (다음 결과가 나오도록 한곳만 수정하기) package chap11; /* * 다음 결과가 나오도록 한곳만 수정하기 * [결과] * basket * basketball */ public class Test0321_1 { public static void main(String[] args) { String str = "base"; //basket System.out.println(str=str.replace('e','k')+"et"); str += "ball"; System.out.println(str); } } 2022. 3. 25. [Java] 29. Test5 (다음의 결과가 나오도록 프로그램을 수정하기) package chap11; /* 다음의 결과가 나오도록 프로그램을 수정하기 [결과] fullPath:c:/jdk17/work/Test.java path:c:/jdk17/work fileName:Test.java */ public class Test0321_5 { public static void main(String[] args) { String fullPath = "c:/jdk17/work/Test.java"; String path=""; String fileName = ""; System.out.println("fullPath:" + fullPath); System.out.println("path:" + path); System.out.println("fileName:" + fileName); } } 2022. 3. 25. [Java] 29. Test4 (결과가 나오도록 함수 구현하기) package chap11; /* * 결과가 나오도록 함수 구현하기 * double round(실수형,소숫점이하 자리수) : 반올림하여 출력 * double truncate(실수형,소숫점이하 자리수) : 버림하여 출력 */ public class Test0321_4 { public static void main(String[] args) { System.out.println(round(3.1215,1)); //3.1 System.out.println(round(3.1215,2)); //3.12 System.out.println(round(3.1215,3)); //3.122 System.out.println(round(3.1215,4)); //3.1215 System.out.println(truncate(.. 2022. 3. 25. [Java] 29. Test3 (문자열 1,234를 정수로 변경하여 1234*10 한 값을 세자리마다 ',' 찍어 출력하기) package chap11; /* * 문자열 1,234를 정수로 변경하여 1234*10 한 값을 세자리마다 , 찍어 출력하기 * [결과] * 12,340 */ public class Test0321_3 { public static void main(String[] args) { String str = "1,234"; } } 2022. 3. 25. 이전 1 ··· 18 19 20 21 22 23 24 ··· 77 다음 728x90 반응형