주제에 대한 기사를 찾고 있습니까 “명품 자바 프로그래밍 실습 문제“? 웹사이트에서 이 주제에 대한 전체 정보를 제공합니다 https://c2.chewathai27.com/ 탐색에서: 457+ 당신을 위한 팁. 바로 아래에서 이 주제에 대한 자세한 답변을 찾을 수 있습니다. 찾고 있는 주제를 더 잘 이해하려면 끝까지 읽으십시오. 더 많은 관련 검색어: 명품 자바 프로그래밍 실습 문제 명품 자바 프로그래밍 실습문제 3장, 명품 자바 프로그래밍 실습문제 4장, 명품 자바 프로그래밍 실습문제 답, 명품 자바 프로그래밍 2장 연습문제, 명품 자바 프로그래밍 2장 실습문제 8번, 명품자바 프로그래밍 1장 실습문제, 명품 자바 프로그래밍 2장 pdf, 명품 자바 프로그래밍 4장 실습문제 10번
명품자바프로그래밍 2장 실습문제 – 코딩맛집
package Luxuryjava02; import java.util.Scanner; public class h0212 { // 연산자 : an operator , 결과 : result public static void main(String[] args) { System.out.print(“연산>>”); Scanner s=new Scanner(System.in); int op1=s.nextInt(); String op=s.next(); int op2=s.nextInt(); int res=0; if(op.equals(“+”)) res=op1+op2; else if(op.equals(“-“)) res=op1-op2; else if(op.equals(“*”)) res=op1*op2; else if(op.equals(“/”)) { if(op2==0) { System.out.print(“0으로 나눌 수 없습니다.”); s.close(); return; } else res=op1/op2; } else { System.out.print(“사칙연산이 아닙니다.”); s.close(); return; } System.out.println(op1+op+op2+”의 계산결과는”+res); s.close(); } }
package Luxuryjava; import java.util.Scanner; public class homework0203 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println(“금액을입력하시오>>”); int num=s.nextInt(); System.out.println(“50000won”+num/50000+”mae”); num%=50000; System.out.println(“10000won”+num/10000+”mae”); num%=10000; System.out.println(“1000won”+num/1000+”mae”); num%=1000; System.out.println(“100won”+num/100+”mae”); num%=100; System.out.println(“50won”+num/50+”mae”); num%=50; System.out.println(“10won”+num/10+”mae”); num%=10; System.out.println(“1won”+num/1+”mae”); s.close(); } }
8 thg 6, 2019 — 명품자바프로그래밍 2장 실습문제. 1. Scanner 클래스를 이용하여 입력받은 원화 값을 달러로 바꾸어 다음 예시와 같이 출력하는 프로그램을 작성하라 …
- Source: coding-restaurant.tistory.com
- Views: 70304
- Publish date: 6 hours ago
- Downloads: 41152
- Likes: 5199
- Dislikes: 3
- Title Website: 명품자바프로그래밍 2장 실습문제 – 코딩맛집
- Description Website: 8 thg 6, 2019 — 명품자바프로그래밍 2장 실습문제. 1. Scanner 클래스를 이용하여 입력받은 원화 값을 달러로 바꾸어 다음 예시와 같이 출력하는 프로그램을 작성하라 …
- Source: Youtube
- Views: 86667
- Date: 45 minute ago
- Download: 66403
- Likes: 3424
- Dislikes: 7
코딩맛집 :: 명품자바프로그래밍 2장 실습문제
명품자바프로그래밍 2장 연습문제
명품자바프로그래밍 2장 요약, 예제
명품자바프로그래밍 2장 실습문제
1. Scanner 클래스를 이용하여 입력받은 원화 값을 달러로 바꾸어
다음 예시와 같이 출력하는 프로그램을 작성하라. ($1=1100원으로 가정)
원화를 입력하세요(단위 원) >> 3300 3300원은 $3.0입니다.
package Luxuryjava; import java.util.Scanner; public class h0201 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println(“원화를 입력하세요(단위:원)>>”); int num=s.nextInt(); double dollar=num/1100; System.out.println(num+”원은 $”+dollar+”입니다.”); s.close(); } }
2. Scanner 클래스를 이용하여 2자리의 정수(10~99사이)를 입력받고,
십의 자리와 1의 자리가 같은 지 판별하여 출력하는 프로그램을 작성하라.
2자리수 정수 입력(10~99) >> 77 Yes! 10의 자리와 1의 자리가 같습니다.
※ Tip. 10의 자리를 10으로 나누고 1의 자리를 10으로 나눈 나머지값이 같은 지를 판별합니다
package Luxuryjava; import java.util.Scanner; public class h0202 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println(“2자리의 정수 입력(10~99)>>”); int num = s.nextInt(); if (num/10==num%10) { System.out.println(“Yes! 10의자리와 1의 자리가 같습니다.”); }else { System.out.println(“No! 10의 자리와 1의 자리가 다릅니다.”); }s.close(); } }
※ 2자리의 정수인지도 판별해 주려면 이렇게 추가해주면 됩니다. 여기서 스캐너는 한 번 밖에 작동되지 않습니다.
package Luxuryjava; import java.util.Scanner; public class h0202 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println(“2자리의 정수 입력(10~99)>>”); int num = s.nextInt(); if (num>=10 && num<100) { if (num/10==num%10) { System.out.println("Yes! 10의자리와 1의 자리가 같습니다."); }else { System.out.println("No! 10의 자리와 1의 자리가 다릅니다."); } } else { System.out.println("2자리의 정수가 아닙니다."); }s.close(); } } 3. 3. Scanner 클래스를 이용하여 정수로 된 돈의 액수를 입력받아 오만 원권, 만 원권, 천 원권, 500원짜리 동전, 100원짜리 동전, 50원짜리 동전, 10원짜리 동전, 1원짜리 동전 각 몇개로 변환되는지 출력하라. #자바지폐단위별숫자구하기 #자바자판기프로그램 #자바잔돈프로그램 금액을 입력하시오 >> 65376 오만 원권 1매 만 원권 1매 천 원권 5매 100원 3개 50원 1개 10원 2개 1원 6개
※ 스캐너 생성, num이라는 변수 생성한 후 입력받은 값을 50,000으로 나눈 몫, 50,000으로 나눈 나머지, 위에서 나온 나머지를 10,000으로 나눈 몫, 그리고 10,000으로 나눈 나머지 …. 이것을 1원까지 반복해주는 것입니다. 마지막 1원은 나머지가 없으므로 나누기만 하고 끝납니다.
package Luxuryjava; import java.util.Scanner; public class homework0203 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println(“금액을입력하시오>>”); int num=s.nextInt(); System.out.println(“50000won”+num/50000+”mae”); num%=50000; System.out.println(“10000won”+num/10000+”mae”); num%=10000; System.out.println(“1000won”+num/1000+”mae”); num%=1000; System.out.println(“100won”+num/100+”mae”); num%=100; System.out.println(“50won”+num/50+”mae”); num%=50; System.out.println(“10won”+num/10+”mae”); num%=10; System.out.println(“1won”+num/1+”mae”); s.close(); } }
※ 배열로 푸는 법. 2장에서는 배우지 않았지만 훨씬 간단합니다.
package Luxuryjava; import java.util.Scanner; public class h0203 { public static void main(String[] args) { int[] coin = {50000, 10000, 1000, 500, 100, 50, 10, 1}; Scanner s=new Scanner(System.in); System.out.println(“금액을 입력하시오>>”); int num=s.nextInt(); for (int i=0; i
> 20 100 33 중간 값은 33 ※ 변수 세개와 스캐너 세번 선언! if-else, else if 구문을 사용하여 a>”); a=s.nextInt(); b=s.nextInt(); c=s.nextInt(); if(a> 4 3 5 삼각형이 됩니다.
※ 삼각형이 되려면 가장 긴 변이 2변의 합보다 작아야 합니다.
package Luxuryjava; import java.util.Scanner; public class h0205 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println(“정수 3개를 입력>>”); int l1=s.nextInt(); int l2=s.nextInt(); int l3=s.nextInt(); if((l1+l2)
> 36 박수짝짝
※ if조건문과 연산자 (0일 경우, 범위가 아닐 경우도 넣기)
package Luxuryjava; import java.util.Scanner; public class h0206 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.print(“1~99 사이의 정수를 입력하시오>>”); int num=s.nextInt(); if(num!=0 && num>=1 && num <=99) { int a,b; a=num/10; b=num%10; if((a==3 || a==6 || a==9) && (b==3 || b==6 || b==9)) { System.out.println("박수짝짝"); }else if((a==3 || a==6 || a==9) || (b==3 || b==6 || b==9)) { System.out.println("박수짝"); } } else { System.out.println("숫자의 범위를 벗어났습니다."); } s.close(); } } 7. 2차원 평면에서 직사각형은 왼쪽 상단 모서리와 오른쪽 하단 모서리의 두 점으로 표현한다. 100,100과 200,200의 두 점으로 이루어진 사각형이 있을 때 Scanner를 이용하여 정수 x와 y 값을 입력받고 점 (x,y)가 이 직사각형 안에 있는 지를 판별하는 프로그램을 작성하라. 점 (x,y)의 좌표를 입력하시오 >> 150 150
(150,150)은 사각형 안에 있습니다.
※ if조건과 논리
package Luxuryjava; import java.util.Scanner; public class h0207 { public static void main(String[] args) { System.out.println(“점 (x,y)의 좌표를 입력하시오 >>”); Scanner s=new Scanner(System.in); int x=s.nextInt(); int y=s.nextInt(); if((100<=x && x<=200)&&(100<=y && y<=200)) System.out.println("사각형 안에 점이 있습니다."); else System.out.println("사각형 안에 점이 없습니다."); s.close(); } } 8. 2차원 평면에서 직사각형은 문제 7번처럼 두 점으로 표현된다. 키보드로부터 사각형을 구성하는 두 점(x1, y1), (x2, y2)를 입력받아 100,100과 200,200의 두 점으로 이루어진 사각형과 충돌하는지 판별하는 프로그램을 작성하라. (아래 코드를 참고하여 만드시오) #자바사각형안의점 #자바사각형충돌 다음은 점(x,y)가 사각형 (rectx1, recty1), (rectx2, recty2) 안에 있으면 true를 리턴하는 메소드이다. 이를 활용하라. public static boolean inRect(int x, int y, int rectx1, int rectx2, int recty1, int recty2){ if ((x>=rectx1 && x<=rectx2) && (y>=recty1 && y<=recty2)) { return true; } else { return false; } } ※ if조건과 논리 : 한 꼭지점이 걸칠 경우, 모든 꼭지점이 안에 있는 경우, (100,100),(200,200)의 모든 꼭지점이 사각형 안에 있는 경우 (만든 사각형이 더 큰 경우) package Luxuryjava; import java.util.Scanner; public class h0208 { public static boolean inRect(int x, int y, int rectx1, int rectx2, int recty1, int recty2) { if((x>=rectx1 && x<=rectx2) && (y>=recty1 && y<=recty2)) return true; else return false; } public static void main(String[] args) { System.out.println("두 점 (x1,y1), (x2,y2)의 좌표를 입력하시오 >>”); Scanner s=new Scanner(System.in); int x1=s.nextInt(); int y1=s.nextInt(); int x2=s.nextInt(); int y2=s.nextInt(); if (inRect(x1,y1,100,100,200,200) || inRect(x2,y2,100,100,200,200) || inRect(x1,y2,100,100,200,200) || inRect(x2,y1,100,100,200,200)) System.out.println(“사각형이 겹칩니다.”); else if ((inRect(x1,y1,100,100,200,200)) && inRect(x2,y2,100,100,200,200) && inRect(x2,y1,100,100,200,200) && inRect(x1,y2,100,100,200,200)) System.out.println(“사각형이 겹칩니다.”); else if ((inRect(100,100,x1,y1,x2,y2)) && inRect(100,200,x1,y1,x2,y2) && inRect(200,100,x1,y1,x2,y2) && inRect(200,200,x1,y1,x2,y2)) System.out.println(“사각형이 겹칩니다.”); else System.out.println(“사각형이 겹치지 않습니다.”); s.close(); } }
※ 주어진 inRect를 사용하지 않고 푸는 방법
package Luxuryjava; import java.util.Scanner; public class h02081 { public static void main(String[] args) { System.out.println(“두 점 (x1,y1), (x2,y2)의 좌표를 입력하시오 >>”); Scanner s=new Scanner(System.in); int x1=s.nextInt(); int y1=s.nextInt(); int x2=s.nextInt(); int y2=s.nextInt(); if ((x1>=100 & x1<=200) && (y1>=100 && y1<=200)) { System.out.println("사각형이 겹침"); }else if((x2>=100 && x2<200) && (y2>=100 && y2<=200)) { System.out.println("사각형이 겹침"); }else if(x1<=100 && x2>=200 && y1<=100 && y2>=200) { System.out.println(“사각형이 겹침”); } else System.out.println(“사각형이 안겹침”); s.close(); } }
9. 원의 중심을 나타내는 한 점과 반지름을 실수 값으로 입력받아라. 그리고 실수 값으로 다른 점 (x.y) 을 입력받아 이 점이 원의 내부에 있는지 판별하여 출력하라. #자바원충돌
원의 중심과 반지름 입력>> 10 10 6.5 점 입력>> 13 13 점 (13.0,13.0)은 원 안에 있습니다. ※ 중심에서 점 ( x,y ) 사이의 거리가 반지름보다 작거나 같으면 원의 내부에 있다. 변수 x에 대한 제곱근의 값은 Math.sqrt(x)를 이용하면 된다. (Math함수는 6장 참고) ※ Math.sqrt : 제곱근(루트) 값을 계산해주는 함수
※ 원의 중심과 점의 거리가 반지름 길이와 같거나 작아야 합니다.
√(x2-x1)2 + (y2-y1)2 , 원의 넓이 = 반지름2 *원주
package Luxuryjava; import java.util.Scanner; public class h0209 { public static void main(String[] args) { System.out.println(“원의 중심과 반지름 입력>>”); Scanner s=new Scanner(System.in); double p1=s.nextDouble(); double p2=s.nextDouble(); double r=s.nextDouble(); System.out.println(“점 입력>>”); double x=s.nextDouble(); double y=s.nextDouble(); double distance=Math.sqrt((x-p1)*(x-p1)+(y-p2)*(y-p2)); if(distance
> 10 10 3 두번째 원의 중심과 반지름 입력>> 12 12 2 두 원은 서로 겹친다.
※ 두 개의 반지름의 합보다 작으면 원이 겹칩니다.
package Luxuryjava02; import java.util.Scanner; public class h0210 { public static void main(String[] args) { System.out.println(“첫 번째 원의 중심과 반지름 입력>>”); Scanner s=new Scanner(System.in); int x=s.nextInt(); int x1=s.nextInt(); double r=s.nextDouble(); System.out.println(“두 번째 원의 중심과 반지름 입력>>”); int y=s.nextInt(); int y1=s.nextInt(); double r1=s.nextDouble(); double distance=0; distance = Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1)); if (distance<=r+r1) System.out.println("두 원은 서로 겹친다."); else System.out.println("두 원은 서로 안겹친다."); s.close(); } } 11. 숫자를 입력받아 3~5는 봄, 6~8은 여름, 9~11은 가을, 12,1,2는 겨울, 그 외의 숫자를 입력한 경우 잘못입력을 출력하는 프로그램을 작성하라. if-else 문과 switch 둘 다 이용해볼 것. 달을 입력하세요(1~12) >> 9
가을
(1) if-else
package Luxuryjava; import java.util.Scanner; public class h0211 { public static void main(String[] args) { System.out.println(“달을 입력하세요(1~12)>>”); Scanner m=new Scanner(System.in); int num=m.nextInt(); if (num>=3 && num<=5) System.out.println("봄"); else if(num>=6 && num<=8) System.out.println("여름"); else if(num>=9 && num<=11) System.out.println("가을"); else if(num==12 || num==1 || num==2) System.out.println("겨울"); else System.out.println("잘못된 만남이 아니고 입력"); m.close(); } } (2) switch package Luxuryjava; import java.util.Scanner; public class h02111 { public static void main(String[] args) { System.out.println("달을 입력하세요(1~12)>>”); Scanner m=new Scanner(System.in); int num=m.nextInt(); switch(num) { case 3: case 4: case 5: System.out.println(“봄”); break; case 6: case 7: case 8: System.out.println(“여름”); break; case 9: case 10: case 11: System.out.println(“가”); break; case 12: case 1: case 2: System.out.println(“겨울”); break; default: System.out.println(“잘못입력”); } m.close(); } }
12. 사칙 연산을 입력받아 계산하는 프로그램을 작성하고자 한다. 연산자는 + – * / 의 네 가지로 하고 피연산자는 모두 실수로 한다. 피연산자와 연산자는 실행 사례와 같이 빈 칸으로 분리하여 입력한다. 0으로 나누기 시 “0으로 나눌 수 없습니다.”를 출력하고 종료한다.
연산 >> 2+4
2+4의 계산 결과는 6
※ 문자열 s가 “+”와 같은 지 검사하려면 if(s.equals.(“+”))를 이용하며, true이면 s와 “+”가 같다.
package Luxuryjava02; import java.util.Scanner; public class h0212 { // 연산자 : an operator , 결과 : result public static void main(String[] args) { System.out.print(“연산>>”); Scanner s=new Scanner(System.in); int op1=s.nextInt(); String op=s.next(); int op2=s.nextInt(); int res=0; if(op.equals(“+”)) res=op1+op2; else if(op.equals(“-“)) res=op1-op2; else if(op.equals(“*”)) res=op1*op2; else if(op.equals(“/”)) { if(op2==0) { System.out.print(“0으로 나눌 수 없습니다.”); s.close(); return; } else res=op1/op2; } else { System.out.print(“사칙연산이 아닙니다.”); s.close(); return; } System.out.println(op1+op+op2+”의 계산결과는”+res); s.close(); } }
명품 자바 프로그래밍 3장 실습 문제 / 2021.07.29 – 코딩은 즐거워
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 package Chapter3; public class Programming { public static void main( String [] args) { int array [][] = new int [ 4 ][ 4 ]; int count = 0 ; for ( int i = 0 ; i < array. length ; i + + ) { for ( int j = 0 ; j < array[i]. length ; j + + ) { array[i][j] = 0 ; } } while (count < 10 ) { int row = ( int )(Math.random() * 4 ); int col = ( int )(Math.random() * 4 ); if (array[row][col] ! = 0 ) { continue ; } else { array[row][col] = ( int )Math.round(Math.random() * 9 + 1 ); count + + ; } } for ( int i = 0 ; i < array. length ; i + + ) { for ( int j = 0 ; j < array[i]. length ; j + + ) { System . out . print (array[i][j] + "\t" ); } System . out . println (); } } } Colored by Color Scripter cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); String course [] = { “Java” , “C++” , “HTML5” , “컴퓨터구조” , “안드로이드” }; int score [] = { 95 , 88 , 76 , 62 , 55 }; int count = 0 ; while ( true ) { System . out . print ( “과목 이름 >> ” ); String name = sc.nextLine(); if (name. equals ( “그만” )) break ; for ( int i = 0 ; i < course. length ; i + + ) { if (course[i]. equals (name)) { System . out . println (course[i] + "의 점수는 " + score[i]); count + + ; } } if (count = = 0 ) System . out . println ( "없는과목입니다." ); } sc.close(); } } Colored by Color Scripter cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); System . out . print ( “정수 몇개? ” ); int number = sc.nextInt(); int [] array = new int [number]; for ( int i = 0 ; i < array. length ; i + + ) { array[i] = ( int )(Math.random() * 100 + 1 ); for ( int j = 0 ; j < i; j + + ) { if (array[i] = = array[j]) i - - ; } } for ( int i = 0 ; i < array. length ; i + + ) { System . out . print (array[i] + " " ); if ((i + 1 ) % 10 = = 0 ) System . out . println (); } } } Colored by Color Scripter cs
29 thg 7, 2021 — 명품 자바 프로그래밍 3장 실습 문제 / 2021.07.29 · 1. (1) 무엇을 계산하는 코드이며 실행 결과 출력되는 내용은? i를 0부터 99까지 짝수만 더하는 코드 …
- Source: cow-kite24.tistory.com
- Views: 89190
- Publish date: 14 minute ago
- Downloads: 28462
- Likes: 8227
- Dislikes: 1
- Title Website: 명품 자바 프로그래밍 3장 실습 문제 / 2021.07.29 – 코딩은 즐거워
- Description Website: 29 thg 7, 2021 — 명품 자바 프로그래밍 3장 실습 문제 / 2021.07.29 · 1. (1) 무엇을 계산하는 코드이며 실행 결과 출력되는 내용은? i를 0부터 99까지 짝수만 더하는 코드 …
자바프로그래밍실습 4장
- Source: Youtube
- Views: 32302
- Date: 56 minute ago
- Download: 8413
- Likes: 2229
- Dislikes: 10
명품 자바 프로그래밍 3장 실습 문제 / 2021.07.29
1.
(1) 무엇을 계산하는 코드이며 실행 결과 출력되는 내용은?
i를 0부터 99까지 짝수만 더하는 코드이다.
실행결과 : 2450
(2) 위의 코드를 main( ) 메서드로 만들고 WhileTest 클래스로 완성하라.
1 2 3 4 5 6 7 8 9 10 11 12 package Chapter3; public class WhileTest { public static void main( String [] args) { int sum = 0 , i = 0 ; while (i < 100 ) { sum = sum + i; i + = 2 ; } System . out . println (sum); } } Colored by Color Scripter cs (3) for 문을 이용하여 동일하게 실행되는 ForTest 클래스를 작성하라. 1 2 3 4 5 6 7 8 9 10 11 12 13 package Chapter3; public class ForTest { public static void main( String [] args) { int sum = 0 ; for ( int i = 0 ; i < 100 ; i + = 2 ) { sum + = i; } System . out . println (sum); } } Colored by Color Scripter cs (4) do-while 문을 이용하여 동일하게 실행되는 DoWhileTest 클래스를 작성하라. 1 2 3 4 5 6 7 8 9 10 11 12 13 package Chapter3; public class DoWhileTest { public static void main( String [] args) { int sum = 0 , i = 0 ; do { sum + = i; i + = 2 ; } while (i < 100 ); System . out . println (sum); } } Colored by Color Scripter cs 2. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 package Chapter3; public class Programming { public static void main( String [] args) { int n [][] = {{ 1 }, { 1 , 2 , 3 }, { 1 }, { 1 , 2 , 3 , 4 }, { 1 , 2 }}; for ( int i = 0 ; i < n. length ; i + + ) { for ( int j = 0 ; j < n[i]. length ; j + + ) { System . out . print (n[i][j] + " " ); } System . out . println (); } } } Colored by Color Scripter cs 3. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); System . out . print ( "정수를 입력하시오>> ” ); int num = sc.nextInt(); for ( int i = 0 ; i < num; i + + ) { for ( int j = num - i; j > 0 ; j – – ) { System . out . print ( “*” ); } System . out . println (); } } } Colored by Color Scripter cs
4.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); System . out . print ( “소문자 알파벳 하나를 입력하시오>> ” ); char alpha = sc.next(). charAt ( 0 ); for ( int i = 0 ; i < = alpha - 'a' ; i + + ) { for ( char j = 'a' ; j < = alpha - i ; j + + ) { System . out . print (j); } System . out . println (); } } } Colored by Color Scripter cs 5. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); int [] array = new int [ 10 ]; System . out . print ( "양의 정수 10개를 입력하시오>> ” ); for ( int i = 0 ; i < array. length ; i + + ) { array[i] = sc.nextInt(); } System . out . print ( "3의 배수는 " ); for ( int i = 0 ; i < array. length ; i + + ) { if (array[i] % 3 = = 0 ) { System . out . print (array[i] + " " ); } } } } Colored by Color Scripter cs 6. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); int [] unit = { 50000 , 10000 , 1000 , 500 , 100 , 50 , 10 , 1 }; System . out . print ( "금액을 입력하시오>> ” ); int money = sc.nextInt(); for ( int i = 0 ; i < unit. length ; i + + ) { if ((money / unit[i]) ! = 0 ) System . out . println (unit[i] + "원 짜리 : " + (money / unit[i]) + "개" ); money % = unit[i]; } sc.close(); } } Colored by Color Scripter cs 7. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 package Chapter3; public class Programming { public static void main( String [] args) { int [] array = new int [ 10 ]; double sum = 0 ; System . out . print ( "랜덤한 정수들 : " ); for ( int k = 0 ; k < array. length ; k + + ) { array[k] = ( int )(Math.random() * 10 + 1 ); System . out . print (array[k] + " " ); sum + = array[k]; } System . out . println (); System . out . println ( "평균은 " + (sum / array. length )); } } Colored by Color Scripter cs 8. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); System . out . print ( "정수 몇개? " ); int number = sc.nextInt(); int [] array = new int [number]; for ( int i = 0 ; i < array. length ; i + + ) { array[i] = ( int )(Math.random() * 100 + 1 ); for ( int j = 0 ; j < i; j + + ) { if (array[i] = = array[j]) i - - ; } } for ( int i = 0 ; i < array. length ; i + + ) { System . out . print (array[i] + " " ); if ((i + 1 ) % 10 = = 0 ) System . out . println (); } } } Colored by Color Scripter cs 9. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 package Chapter3; public class Programming { public static void main( String [] args) { int array [][] = new int [ 4 ][ 4 ]; for ( int i = 0 ; i < 4 ; i + + ) { for ( int j = 0 ; j < 4 ; j + + ) { array[i][j] = ( int )(Math.random() * 10 + 1 ); System . out .printf( "%2d " , array[i][j]); } System . out . println (); } } } Colored by Color Scripter cs 10. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 package Chapter3; public class Programming { public static void main( String [] args) { int array [][] = new int [ 4 ][ 4 ]; int count = 0 ; for ( int i = 0 ; i < array. length ; i + + ) { for ( int j = 0 ; j < array[i]. length ; j + + ) { array[i][j] = 0 ; } } while (count < 10 ) { int row = ( int )(Math.random() * 4 ); int col = ( int )(Math.random() * 4 ); if (array[row][col] ! = 0 ) { continue ; } else { array[row][col] = ( int )Math.round(Math.random() * 9 + 1 ); count + + ; } } for ( int i = 0 ; i < array. length ; i + + ) { for ( int j = 0 ; j < array[i]. length ; j + + ) { System . out . print (array[i][j] + "\t" ); } System . out . println (); } } } Colored by Color Scripter cs 11~12번 건너 뛰겠습니다. 13. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 package Chapter3; public class Programming { public static void main( String [] args) { int i = 1 ; while (i < 100 ) { int count = 0 ; if ((i / 10 = = 3 ) | | (i / 10 ) = = 6 | | (i / 10 ) = = 9 ) count + + ; if ((i% 10 = = 3 ) | | (i% 10 ) = = 6 | | (i% 10 ) = = 9 ) count + + ; if (count = = 1 ) { System . out . println (i + " 박수 짝" ); } if (count = = 2 ) { System . out . println (i + " 박수 짝짝" ); } i + + ; } } } Colored by Color Scripter cs 14. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 package Chapter3; import java.util. Scanner ; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); String course [] = { "Java" , "C++" , "HTML5" , "컴퓨터구조" , "안드로이드" }; int score [] = { 95 , 88 , 76 , 62 , 55 }; int count = 0 ; while ( true ) { System . out . print ( "과목 이름 >> ” ); String name = sc.nextLine(); if (name. equals ( “그만” )) break ; for ( int i = 0 ; i < course. length ; i + + ) { if (course[i]. equals (name)) { System . out . println (course[i] + "의 점수는 " + score[i]); count + + ; } } if (count = = 0 ) System . out . println ( "없는과목입니다." ); } sc.close(); } } Colored by Color Scripter cs 15. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package Chapter3; import java.util. Scanner ; import java.util.InputMismatchException; public class Programming { public static void main( String [] args) { Scanner sc = new Scanner ( System . in ); while ( true ) { System . out . print ( "곱하고자 하는 두 수 입력>>” ); try { int n = sc.nextInt(); int m = sc.nextInt(); System . out . print (n + “X” + m + “=” + n * m); break ; } catch (InputMismatchException e) { System . out . println ( “실수는 입력하면 안됩니다.” ); sc.nextLine(); continue ; } } sc.close(); } } Colored by Color Scripter cs
16.
명품 자바 프로그래밍(개정4판) 제 2장 실습문제
import java.util.Scanner; public class p0203 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“금액을 입력하시오>>”); int money=sc.nextInt(); System.out.println(“오만원권 “+money/50000+”매”); money%=50000; System.out.println(“만원권 “+money/10000+”매”); money%=10000; System.out.println(“천원권 “+money/1000+”매”); money%=1000; /* 문제에선 언급되었지만 출력에는 없어서 고려x System.out.println(“오백원 “+money/500+”개”); money%=500; */ System.out.println(“백원 “+money/100+”개”); money%=100; System.out.println(“오십원 “+money/50+”개”); money%=50; System.out.println(“십원 “+money/10+”개”); money%=10; System.out.println(“일원 “+money+”개”); sc.close(); } }
import java.util.Scanner; public class practice { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“연산>>”); int a=sc.nextInt(); String op=sc.next(); int b=sc.nextInt(); if(op.equals(“+”)){ System.out.println(a+op+b+”의 계산 결과는 “+(a+b)); } else if(op.equals(“-“)) { System.out.println(a+op+b+”의 계산 결과는 “+(a-b)); } else if(op.equals(“*”)) { System.out.println(a+op+b+”의 계산 결과는 “+(a*b)); } else if(op.equals(“/”)) { if(b==0) { System.out.println(“0으로 나눌 수 없습니다.”); } else { System.out.println(a+op+b+”의 계산 결과는 “+(a/b)); } } sc.close(); } }
8 thg 10, 2020 — 명품 자바 프로그래밍(개정4판) 제 2장 실습문제 … 원화를 입력받고 환전한 값(money/1100.0) 을 출력, 출력이 double형이므로 피연산자중 하나를 double …
- Source: khu98.tistory.com
- Views: 92498
- Publish date: 13 hours ago
- Downloads: 55688
- Likes: 9863
- Dislikes: 2
- Title Website: 명품 자바 프로그래밍(개정4판) 제 2장 실습문제
- Description Website: 8 thg 10, 2020 — 명품 자바 프로그래밍(개정4판) 제 2장 실습문제 … 원화를 입력받고 환전한 값(money/1100.0) 을 출력, 출력이 double형이므로 피연산자중 하나를 double …
자바프로그래밍실습 3장
- Source: Youtube
- Views: 92559
- Date: 8 hours ago
- Download: 95696
- Likes: 2874
- Dislikes: 5
명품 자바 프로그래밍(개정4판) 제 2장 실습문제
[1번]import java.util.Scanner; public class p0201 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“원화를 입력하세요(단위 원)>>”); int money=sc.nextInt(); System.out.println(money+”원은 $”+money/1100.0+”입니다.”); sc.close(); } }
원화를 입력받고 환전한 값(money/1100.0) 을 출력, 출력이 double형이므로 피연산자중 하나를 double형으로 하면 형변환으로 인해 출력이 double로 된다.
[2번]import java.util.Scanner; public class p0202 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“2자리수 정수 입력(10~99)>>”); int num=sc.nextInt(); if(num<10||num>99) { System.out.println(“범위를 벗어났습니다.”); } else if(num%10==num/10) { System.out.println(“Yes! 10의 자리와 1의 자리가 같습니다.”); } else { System.out.println(“No! 10의 자리와 1의 자리가 같지 않습니다.”); } sc.close(); } }
[3번]import java.util.Scanner; public class p0203 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“금액을 입력하시오>>”); int money=sc.nextInt(); System.out.println(“오만원권 “+money/50000+”매”); money%=50000; System.out.println(“만원권 “+money/10000+”매”); money%=10000; System.out.println(“천원권 “+money/1000+”매”); money%=1000; /* 문제에선 언급되었지만 출력에는 없어서 고려x System.out.println(“오백원 “+money/500+”개”); money%=500; */ System.out.println(“백원 “+money/100+”개”); money%=100; System.out.println(“오십원 “+money/50+”개”); money%=50; System.out.println(“십원 “+money/10+”개”); money%=10; System.out.println(“일원 “+money+”개”); sc.close(); } }
[4번]import java.util.Scanner; public class p0204 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“정수 3개를 입력하시오>>”); int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int result; if(b>”); int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); if((a+b)
[9번]>”); int num=sc.nextInt(); int cnt=0; if(num%10==3||num%10==6||num%10==9) { cnt++; } num/=10; if(num>=1&&num<=99) { if(num%10==3||num%10==6||num%10==9) { cnt++; } if(cnt==1) { System.out.println("박수짝"); } else if(cnt==2) { System.out.println("박수짝짝"); } else { System.out.println(""); } } else { System.out.println("범위를 벗어났습니다."); } sc.close(); } } [7번] import java.util.Scanner; public class p0207 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print("점 (x,y)의 좌표를 입력하시오>>”); int x=sc.nextInt(); int y=sc.nextInt(); if((x>=100&&x<=200)&&(y>=100&&y<=200)) { System.out.println("("+x+","+y+")는 사각형 안에 있습니다."); } else { System.out.println("("+x+","+y+")는 사각형 안에 없습니다."); } sc.close(); } } [8번] import java.util.Scanner; public class p0208 { public static boolean inRect(int x, int y, int rectx1, int recty1, int rectx2, int recty2) { if((x>=rectx1 && x<=rectx2) && (y>=recty1 && y<=recty2)) return true; else return false; } public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print("두 점 (x1,y1), (x2,y2)의 좌표를 입력하시오>>”); int x1=sc.nextInt(); int y1=sc.nextInt(); int x2=sc.nextInt(); int y2=sc.nextInt(); boolean result;//사각형이 충돌하는지 if (inRect(x1,y1,100,100,200,200) || inRect(x2,y2,100,100,200,200) || inRect(x1,y2,100,100,200,200) || inRect(x2,y1,100,100,200,200)) { result=true; } else if ((inRect(x1,y1,100,100,200,200)) && inRect(x2,y2,100,100,200,200) && inRect(x2,y1,100,100,200,200) && inRect(x1,y2,100,100,200,200)) { result=true; } else if ((inRect(100,100,x1,y1,x2,y2)) && inRect(100,200,x1,y1,x2,y2) && inRect(200,100,x1,y1,x2,y2) && inRect(200,200,x1,y1,x2,y2)) { result=true; } else { result=false; } //겹치면 if(result) { System.out.println(“사각형이 겹칩니다.”); } //안겹치면 else { System.out.println(“사각형이 겹치지 않습니다.”); } sc.close(); } } import java.util.Scanner; public class p0209 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“원의 중심과 반지름 입력>>”); double rx=sc.nextDouble(); double ry=sc.nextDouble(); double r=sc.nextDouble(); System.out.print(“점 입력>>”); double x=sc.nextDouble(); double y=sc.nextDouble(); double d=(rx-x)*(rx-x)+(ry-y)*(ry-y); if(r*r>=d) { System.out.println(“점 (“+x+”,”+y+”)는 원 안에 있다.”); } else { System.out.println(“점 (“+x+”,”+y+”)는 원 안에 없다.”); } sc.close(); } }
[10번]import java.util.Scanner; public class p0210 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“첫번째 원의 중심과 반지름 입력>>”); int x1=sc.nextInt(); int y1=sc.nextInt(); int r1=sc.nextInt(); System.out.print(“두번째 원의 중심과 반지름 입력>>”); int x2=sc.nextInt(); int y2=sc.nextInt(); int r2=sc.nextInt(); int d=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); if(Math.sqrt(d)<=r1+r2) { System.out.println("두 원은 서로 겹친다."); } else { System.out.println("두 원은 서로 겹치지 않는다."); } sc.close(); } } [11-1번] import java.util.Scanner; public class p0211 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print("달을 입력하세요(1~12)>>”); int month=sc.nextInt(); if(month>=3&&month<=5) { System.out.println("봄"); } else if(month>=6&&month<=8) { System.out.println("여름"); } else if(month>=9&&month<=11) { System.out.println("가을"); } else if(month==1||month==2||month==12) { System.out.println("겨울"); } else { System.out.println("잘못입력."); } sc.close(); } } [11-2번] import java.util.Scanner; public class p0211{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print("달을 입력하세요(1~12)>>”); int month=sc.nextInt(); switch(month) { case 12: case 1: case 2: System.out.println(“겨울”); break; case 3: case 4: case 5: System.out.println(“봄”); break; case 6: case 7: case 8: System.out.println(“여름”); break; case 9: case 10: case 11: System.out.println(“가을”); break; default: System.out.println(“잘못입력”); } sc.close(); } }
[12-1번]import java.util.Scanner; public class practice { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.print(“연산>>”); int a=sc.nextInt(); String op=sc.next(); int b=sc.nextInt(); if(op.equals(“+”)){ System.out.println(a+op+b+”의 계산 결과는 “+(a+b)); } else if(op.equals(“-“)) { System.out.println(a+op+b+”의 계산 결과는 “+(a-b)); } else if(op.equals(“*”)) { System.out.println(a+op+b+”의 계산 결과는 “+(a*b)); } else if(op.equals(“/”)) { if(b==0) { System.out.println(“0으로 나눌 수 없습니다.”); } else { System.out.println(a+op+b+”의 계산 결과는 “+(a/b)); } } sc.close(); } }
[12-2번]
명품 자바 프로그래밍 실습 문제 3 장 8 번
4 ngày trước — 책: 명품 JAVA Programming. * 문제: 실습문제 3장 8번 (3-8) * 정수를 몇 개 저장할지 키보드로부터 개수를 입력받아 (100보다 작은 개수) 정수 배열 …
- Source: 704406008.taxisrecko.si
- Views: 89621
- Publish date: 50 minute ago
- Downloads: 54529
- Likes: 8298
- Dislikes: 6
- Title Website: 명품 자바 프로그래밍 실습 문제 3 장 8 번
- Description Website: 4 ngày trước — 책: 명품 JAVA Programming. * 문제: 실습문제 3장 8번 (3-8) * 정수를 몇 개 저장할지 키보드로부터 개수를 입력받아 (100보다 작은 개수) 정수 배열 …
자바프로그래밍실습 6장
- Source: Youtube
- Views: 38305
- Date: 42 minute ago
- Download: 17993
- Likes: 7661
- Dislikes: 8
주제에 대한 관련 정보 명품 자바 프로그래밍 실습 문제
Bing에서 명품 자바 프로그래밍 실습 문제 주제에 대한 최신 정보를 볼 수 있습니다.
주제에 대한 기사 보기를 마쳤습니다 명품 자바 프로그래밍 실습 문제. 이 기사가 유용했다면 공유하십시오. 매우 감사합니다. 사람들이 이 주제와 관련하여 자주 검색하는 키워드: 명품 자바 프로그래밍 실습 문제 명품 자바 프로그래밍 실습문제 3장, 명품 자바 프로그래밍 실습문제 4장, 명품 자바 프로그래밍 실습문제 답, 명품 자바 프로그래밍 2장 연습문제, 명품 자바 프로그래밍 2장 실습문제 8번, 명품자바 프로그래밍 1장 실습문제, 명품 자바 프로그래밍 2장 pdf, 명품 자바 프로그래밍 4장 실습문제 10번