자바로 배우는 프로그래밍 기초 9장
본 자료는 6페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
해당 자료는 6페이지 까지만 미리보기를 제공합니다.
6페이지 이후부터 다운로드 후 확인할 수 있습니다.

목차

1. 9장 내용점검

2. 9장 프로그래밍 연습

본문내용

);
}
}
System.out.println("\n\t<<두 행렬의 뺀 행렬은 MINUS행렬이다.>>\n");
for(int i=0; i for(int j=0; j System.out.print("MINUS배열의 [" + (i+1) + "][" + (j+1) + "]=> "
+sum(x,y)[i][j] + "\t");
}
System.out.println();
}
}
public static int[][] sum(int a[][] , int b[][]) {
int c[][] = new int[3][3];
for(int i = 0; i < c.length; i++)
for(int j = 0 ; j < c.length; j++)
c[i][j] = a[i][j] - b[i][j];
return c;
}
}
4. 두 행렬의 곱하기를 수행하는 메소드를 만들어 검사하는 프로그램을 작성하시오.
import java.util.Scanner;
public class no4 {
public static void main(String[] args) {
int x[][] = new int[3][2];
int y[][] = new int[2][3];
Scanner s = new Scanner(System.in);
for(int i=0; i System.out.print("첫번째(3*2)행렬의 [" + (i+1) + "]번째 행의 숫자(2 개) 입력: ");
for(int j=0; j x[i][j] = s.nextInt();
}
System.out.println();
for(int i=0; i System.out.print("두번째 2*3)행렬의 [" + (i+1) + "]번째 행의 숫자(3 개) 입력: ");
for(int j=0; j y[i][j] = s.nextInt();
}
System.out.println();
System.out.println("\n\t<<두 배열을 곱셈한 배열은 TIME배열이다.>>\n");
for(int i=0; i for(int j=0; j System.out.print("TIME행렬 [" + (i+1) + "][" + (j+1) + "]=> "
+ TIME(x,y)[i][j] + "\t");
}
System.out.println();
}
}
public static int[][] TIME(int a[][], int b[][]) {
int c[][] = new int[a.length][b[0].length];
for(int i=0; i for(int j=0; j for(int k=0; k c[i][j] += a[i][k] * b[k][j];
}
return c;
}
}
5. 원, 사각형, 삼각형의 면적을 구하는 정적 메소드를 만들어 검사하는 프로그램을
작성하시오.
import java.util.Scanner;
public class no5 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("원의 반지름 입력: ");
double radius = s.nextDouble();
System.out.println("\t반지름이 " + radius + "인 원의 면적= " + Area(radius));
System.out.print("\n사각형의 가로, 세로 입력: ");
double width = s.nextDouble();
double height = s.nextDouble();
System.out.println("\t가로가 " + width + ", 세로가 " + height +
" 인 사각형의 면적= " + Area(width,height));
System.out.print("\n삼각형의 밑변, 높이 입력: ");
double base = s.nextDouble();
double highly = s.nextDouble();
System.out.println("\t밑변이 " + base + ", 높이가 " + highly +
" 인 사각형의 면적= " + Area(base,highly,2));
}
public static double Area(double a) {
double area = 3.14 * a * a;
return area;
}
public static double Area(double a, double b) {
double area = a * b;
return area;
}
public static double Area(double a, double b, int c) {
double area = a * b /c;
return area;
}
}
6. 인자로 문자열 두 개를 받아 이 두 문자열을 연결하는 반환하는 메소드를 작성하고
검사하는 프로그램을 작성하시오.
import java.util.Scanner;
public class no6 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("두 문자열을 입력하세요.");
System.out.print("첫번째 문자열 입력: ");
String str1 = s.next();
System.out.print("두번째 문자열 입력: ");
String str2 = s.next();
s.close();
System.out.print("\n두 문자열을 연결한 결과");
System.out.print("=> " + str(str1,str2));
}
public static String str(String str1, String str2) {
String str3 = str1 + str2;
return str3;
}
}
  • 가격2,000
  • 페이지수19페이지
  • 등록일2008.05.31
  • 저작시기2007.11
  • 파일형식한글(hwp)
  • 자료번호#467045
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니