목차
1. 9장 내용점검
2. 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;
}
}
}
}
System.out.println("\n\t<<두 행렬의 뺀 행렬은 MINUS행렬이다.>>\n");
for(int i=0; i
+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
for(int j=0; j
}
System.out.println();
for(int i=0; i
for(int j=0; j
}
System.out.println();
System.out.println("\n\t<<두 배열을 곱셈한 배열은 TIME배열이다.>>\n");
for(int i=0; i
+ 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
}
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;
}
}
키워드
추천자료
Programing Language Chapter 2 연습문제
[C언어]프로그래밍(C언어)에 대한 PPT자료
java를 이용한 타자연습프로그램을 만들기 flowchart,statediagram,소스
java 프로그래밍을 이용한 타자 프로그램 프로젝트 세부 리포트
[컴퓨터공학]AWT 패키지와 윈도우 프로그래밍
[컴퓨터공학]AWT 패키지와 윈도우 프로그래밍
2010년 2학기 JAVA프로그래밍 기말시험 핵심체크
객체지향에 대해서 - 객체의 내부구조, 객체 지향, 객체 지향 프로그래밍 도구
소프트웨어공학 연습문제7장
프로그래밍언어론_연습문제풀이(한빛미디어)
JAVA GA 알고리즘 [ 소스 , 주석 ] ( 이해 ok )
2018년 1학기 C프로그래밍 기말시험 핵심체크