대학생 코딩 과제 대행 java, python , oracle 첫 번째
https://open.kakao.com/o/s3aMpbA
심심해서 그리고 여러가지 문제들을 접해보기 위해서 카톡 공개채팅방을 대학생 java , python 코딩 대행 해준다는 제목으로 열었었다.
첫번째 과제


두번째 과제는 텍스트로 받았다.
사진으로 보기 불편해서 텍스트 파일로 달라고했다.
----------------------------------------------------------
20점 만점 + 보너스 2점 과제입니다.
보너스 점수는 과제를 만점 받은 경우에만 부여합니다.
옵션1 또는 옵션2를 수행했음을 첨부글에 적는 경우, 각 1점의 추가 보너스 점수를 부여합니다.(첨부글에 적지 않으면 보너스 점수 없음)
----------------------------------------------------------
다음과 같이 정수 리스트를 관리하는 MyList 클래스를 작성하고 사용하는 프로그램을 작성하시오.
- MyList 클래스를 다음과 같이 정의(lab0_7의 MyList에 아래 ***** 부분을 추가하면 됨)
속성(private 인스턴스 변수):
? 정수형 배열 변수
? 저장 용량
? 배열에 저장된 정수 갯수를 나타내는 변수(배열 크기가 아니라 자료 갯수)
기능(public 메소드):
? 생성자(constructor) - 비어있는 MyList를 생성함. 즉, 속성을 다음과 같이 초기화한다.
??크기가 10인 정수 배열을 생성하여 배열 변수 속성을 초기화
??저장 용량을 10으로 초기화
??저장된 정수 갯수를 0으로 초기화
??add - 정수값을 매개변수로 받아 배열에 저장
??저장은 입력 순서대로 배열 앞부분부터 채운다.
??print - 리스트 전체를 한 줄에 출력
??(출력 형식은 자유이나, 가능하면 아래 실행 예와 같은 형식으로 출력해 볼 것)
?***** lab0_7에 추가할 메소드 *****
??get - 인덱스를 매개변수로 받아 배열의 인덱스 위치 원소를 리턴
? set - 인덱스와 정수값을 매개변수로 받아 배열의 인덱스 위치 원소를 정수값으로 지정(대치)
??size - 저장된 정수 개수를 리턴
??add - 인덱스와 정수값을 매개변수로 받아 배열의 인덱스 위치에 삽입
? remove - 인덱스를 매개변수로 받아 배열의 인덱스 위치 원소를 삭제하고 리턴함
? toString - 오버라이드(print에서 출력하는 내용을 출력하지 말고 하나의 String으로 만들어서 리턴)
??????
***** 옵션 *****
(옵션1) add 메소드들에서 저장 용량을 초과하여 원소를 저장하고자 하는 경우,
??? 에러 상황임을 클래스 외부에서는 알지 못하도록 내부적으로 용량을 2배로 늘릴 것
??? (단, 과제 채점을 위해 용량을 몇에서 몇으로 늘리는 작업을 수행했음을 출력할 것)
?
(옵션2) 인덱스를 매개변수로 갖는 메소드들에서 인덱스가 잘못된 범위인 경우
??? 예외 발생하도록 할 것(예외 처리는 하지 않아도 되며, 예외 발생시 프로그램이 멈추면 됨)
??? 여기서 인덱스가 잘못된 범위라는 것은 구현상 배열 크기를 벗어났다는 뜻이 아니라, 논리적으로 인덱스 범위가 잘못되었다는 뜻임
??? (예를 들어 20, 30 삽입 후 인덱스 4 위치에 50을 삽입하고자 하면 예외 발생)
- 드라이버 클래스의 main 메소드는 다음을 수행
? myList 객체를 생성(list라고 부르자)
? list에 20, 30, 20, 40, -999, 50, 90, 10 을 저장
? System.out.println(list);
? (주의: 지금부터의 작업은 위에서 어떤 값이 몇개 저장된지 모르는 상태에서 수행 가능해야 함)
? list의 크기를 출력
? 조회할 인덱스(index1)를 사용자로부터 입력받음
? index1 위치의 값을 알아내어 출력
? 갱신할 인덱스(index2)를 사용자로부터 입력받음
? index2 위치의 값을 777로 지정(대치)
? System.out.println(list);
? 삽입할 인덱스(index3)를 사용자로부터 입력받음
? index3 위치에 999를 삽입
? System.out.println(list);
? 삭제할 인덱스(index4)를 사용자로부터 입력받음
? index4 위치의 값을 삭제하여 출력
? System.out.println(list);
? ***** (옵션1)?***** // 여기부터는 (옵션1) 수행한 경우만 실행
? list에 1부터 25까지 저장
? System.out.println(list);
- 입력: 조회/갱신/삽입/삭제할 인덱스
- 출력: 정수값과 리스트 내용
- toString 오버라이드할 때 다음 두 코드의 효율성 차이를 고려할 것
String str = "";
for(int i=0; i<1000000; i++) {
?? str = str + "a ";
}
return str;?
StringBuffer str = new StringBuffer("");
for(int i=0; i<1000000; i++) {
?? str.append("a ");
}
return str.toString();?
?
- 실행 예
hw5_1 : 홍길동
[20, 30, 20, 40, -999, 50, 90, 10]
리스트 크기 = 8
조회할 인덱스 입력: 7
인덱스 7의 원소 = 555
777로 갱신할 인덱스 입력: 0
[777, 30, 20, 40, -999, 50, 90, 10]
999를 삽입할 인덱스 입력: 2
[777, 30, 999, 20, 40, -999, 50, 90, 10]
삭제할 인덱스 입력: 5
인덱스 5의 원소 = -999
[777, 30, 999, 20, 40, 50, 90, 10]
// 여기부터는 (옵션1) 출력임
용량 증가 10-->20
용량 증가 20-->40
[777, 30, 999, 20, 40, 50, 90, 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]
----------------------------------------------------------
목적
- 순차자료구조 구현을 연습한다.
----------------------------------------------------------
유의사항
- 적절한 comment
//***************************
// 파일명: ... .java
// 작성자: ...
// 작성일: ...
// 설명:...
//***************************
- 들여쓰기
- 식별자 이름을 자바 관례에 맞게 적절히 붙일 것
- command-line에서 java -jar 과제코드.jar 로 채점합니다. 철자도 똑같게 이 명령이 제대로 실행되어야 합니다.
- 과제코드와 본인의 이름을 맨 처음 출력
과제1 -> 과제2 연결된 과제라서
package first;
import java.util.Scanner;
public class Driver {
public static void main(String[] args) {
// TODO Auto-generated method stub
MyList list = new MyList();
list.add(20);
list.add(30);
list.add(20);
list.add(40);
list.add(-999);
list.add(50);
list.add(90);
list.add(10);
System.out.println(list);
System.out.println("리스트의 크기" + list.size());
Scanner scn = new Scanner(System.in);
System.out.println("조회할 인덱스 입력 : "); //7
int index1 = scn.nextInt();
System.out.println("인덱스 7의 원소 : "+ list.get(index1));
System.out.println("777로 갱신할 인덱스 입력 : "); //0
int index2 = scn.nextInt();
list.set(index2, 777);
System.out.println(list);
System.out.println("999로 삽입할 인덱스 입력 : "); //2
int index3 = scn.nextInt();
list.add(index3, 999);
System.out.println(list);
System.out.println("삭제할 인덱스 입력 : "); //5
int index4 = scn.nextInt();
int removedvalue = list.remove(index4);
System.out.println("인덱스"+index4+"의 원소 : "+removedvalue);
System.out.println(list);
System.out.println("*********** (옵션1) ***********");
list.add(10,10);
System.out.println(list);
list.add(20,10);
System.out.println(list);
}
}
class MyList {
private int[] value= new int[10];
private int cnt = 0;
public MyList() {
// TODO Auto-generated method stub
super();
}
public int get(int index){
if(this.value[index]==0){
try {
Exception e = new Exception("고의로 발생시켰음.");
throw e;
} catch (Exception e) {
System.out.println("에러 메시지 : " + e.getMessage());
e.printStackTrace();
}
System.out.println("프로그램이 정상 종료되었음.");
}
int result = this.value[index];
return result;
}
public void set(int index, int integer){
if(this.value[index]==0){
try {
Exception e = new Exception("고의로 발생시켰음.");
throw e;
} catch (Exception e) {
System.out.println("에러 메시지 : " + e.getMessage());
e.printStackTrace();
}
System.out.println("프로그램이 정상 종료되었음.");
}
this.value[index]=integer;
}
public void add(int index, int integer){
int plus =1;
if(index>9){
int[] value2 = new int[this.value.length*2];
for (int j = 0; j < this.value.length; j++) {
value2[j] = this.value[j];
}
this.value = value2;
this.value[index] = integer;
for(int i = 10; i<this.value.length;i++){
this.value[i] = plus;
++plus;
if(plus==26){
break;
}
}
System.out.println("용량 증가"+ this.value.length+" 에서"+(this.value.length*2));
}else{
if(this.value[index]!=0){
for(int i =this.cnt; i>index;i--){
if(this.value[i]==0){
this.value[i]= this.value[i-1];
this.value[i-1]=0;
}
}
}
this.value[index] = integer;
this.cnt +=1;
}
}
public int remove(int index){
if(this.value[index]==0){
try {
Exception e = new Exception("고의로 발생시켰음.");
throw e;
} catch (Exception e) {
System.out.println("에러 메시지 : " + e.getMessage());
e.printStackTrace();
}
System.out.println("프로그램이 정상 종료되었음.");
}
int temp = this.value[index];
this.value[index]=0;
this.cnt -=1;
for(int i = 0; i<this.value.length-1; i++){
if(this.value[i]==0&&this.value[i+1]!=0){
this.value[i] = this.value[i+1];
this.value[i+1] = 0;
}
}
return temp;
}
@Override
public String toString() {
String result="";
if(this.value[0]==0){
result ="[]";
System.out.println(result);
}else{
result ="[";
for(int i =0; i<value.length;i++){
if(this.value[i]!=0){
result += value[i]+","+" ";
}
}
result = result.substring(0, result.length()-2);
result += "]";
}
return result;
// return "MyList [value=" + Arrays.toString(this.value) + ", cnt=" + cnt + "]";
}
public void print(){
if(this.value[0]==0){
String result ="[]";
System.out.println(result);
}else{
String result ="[";
for(int i =0; i<value.length;i++){
if(this.value[i]!=0){
result += value[i]+","+" ";
}
}
result = result.substring(0, result.length()-2);
result += "]";
System.out.println(result);
}
}
public void add(int a){
int plus =1;
if(cnt>=10){
int[] value2 = new int[this.value.length*2];
for (int j = 0; j < this.value.length; j++) {
value2[j] = this.value[j];
}
this.value = value2;
for(int i =0; i<this.value.length; i++){
if(this.value[i]==0){
this.value[i]=a;
this.cnt +=1;
break;
}
}
for(int i = 10; i<this.value.length;i++){
this.value[i] = plus;
++plus;
if(plus==26){
break;
}
}
System.out.println("용량" + this.value.length+"에서"+(this.value.length*2));
}else{
for(int i =0; i<this.value.length; i++){
if(this.value[i]==0){
this.value[i]=a;
this.cnt +=1;
break;
}
}
}
}
public int size() {
int count =0;
for(int i=0; i<this.value.length; i++){
if(this.value[i]==0){
count+=1;
}
}
this.cnt = this.value.length - count;
return this.cnt;
}
}
심심해서 그리고 여러가지 문제들을 접해보기 위해서 카톡 공개채팅방을 대학생 java , python 코딩 대행 해준다는 제목으로 열었었다.
첫번째 과제


두번째 과제는 텍스트로 받았다.
사진으로 보기 불편해서 텍스트 파일로 달라고했다.
----------------------------------------------------------
20점 만점 + 보너스 2점 과제입니다.
보너스 점수는 과제를 만점 받은 경우에만 부여합니다.
옵션1 또는 옵션2를 수행했음을 첨부글에 적는 경우, 각 1점의 추가 보너스 점수를 부여합니다.(첨부글에 적지 않으면 보너스 점수 없음)
----------------------------------------------------------
다음과 같이 정수 리스트를 관리하는 MyList 클래스를 작성하고 사용하는 프로그램을 작성하시오.
- MyList 클래스를 다음과 같이 정의(lab0_7의 MyList에 아래 ***** 부분을 추가하면 됨)
속성(private 인스턴스 변수):
? 정수형 배열 변수
? 저장 용량
? 배열에 저장된 정수 갯수를 나타내는 변수(배열 크기가 아니라 자료 갯수)
기능(public 메소드):
? 생성자(constructor) - 비어있는 MyList를 생성함. 즉, 속성을 다음과 같이 초기화한다.
??크기가 10인 정수 배열을 생성하여 배열 변수 속성을 초기화
??저장 용량을 10으로 초기화
??저장된 정수 갯수를 0으로 초기화
??add - 정수값을 매개변수로 받아 배열에 저장
??저장은 입력 순서대로 배열 앞부분부터 채운다.
??print - 리스트 전체를 한 줄에 출력
??(출력 형식은 자유이나, 가능하면 아래 실행 예와 같은 형식으로 출력해 볼 것)
?***** lab0_7에 추가할 메소드 *****
??get - 인덱스를 매개변수로 받아 배열의 인덱스 위치 원소를 리턴
? set - 인덱스와 정수값을 매개변수로 받아 배열의 인덱스 위치 원소를 정수값으로 지정(대치)
??size - 저장된 정수 개수를 리턴
??add - 인덱스와 정수값을 매개변수로 받아 배열의 인덱스 위치에 삽입
? remove - 인덱스를 매개변수로 받아 배열의 인덱스 위치 원소를 삭제하고 리턴함
? toString - 오버라이드(print에서 출력하는 내용을 출력하지 말고 하나의 String으로 만들어서 리턴)
??????
***** 옵션 *****
(옵션1) add 메소드들에서 저장 용량을 초과하여 원소를 저장하고자 하는 경우,
??? 에러 상황임을 클래스 외부에서는 알지 못하도록 내부적으로 용량을 2배로 늘릴 것
??? (단, 과제 채점을 위해 용량을 몇에서 몇으로 늘리는 작업을 수행했음을 출력할 것)
?
(옵션2) 인덱스를 매개변수로 갖는 메소드들에서 인덱스가 잘못된 범위인 경우
??? 예외 발생하도록 할 것(예외 처리는 하지 않아도 되며, 예외 발생시 프로그램이 멈추면 됨)
??? 여기서 인덱스가 잘못된 범위라는 것은 구현상 배열 크기를 벗어났다는 뜻이 아니라, 논리적으로 인덱스 범위가 잘못되었다는 뜻임
??? (예를 들어 20, 30 삽입 후 인덱스 4 위치에 50을 삽입하고자 하면 예외 발생)
- 드라이버 클래스의 main 메소드는 다음을 수행
? myList 객체를 생성(list라고 부르자)
? list에 20, 30, 20, 40, -999, 50, 90, 10 을 저장
? System.out.println(list);
? (주의: 지금부터의 작업은 위에서 어떤 값이 몇개 저장된지 모르는 상태에서 수행 가능해야 함)
? list의 크기를 출력
? 조회할 인덱스(index1)를 사용자로부터 입력받음
? index1 위치의 값을 알아내어 출력
? 갱신할 인덱스(index2)를 사용자로부터 입력받음
? index2 위치의 값을 777로 지정(대치)
? System.out.println(list);
? 삽입할 인덱스(index3)를 사용자로부터 입력받음
? index3 위치에 999를 삽입
? System.out.println(list);
? 삭제할 인덱스(index4)를 사용자로부터 입력받음
? index4 위치의 값을 삭제하여 출력
? System.out.println(list);
? ***** (옵션1)?***** // 여기부터는 (옵션1) 수행한 경우만 실행
? list에 1부터 25까지 저장
? System.out.println(list);
- 입력: 조회/갱신/삽입/삭제할 인덱스
- 출력: 정수값과 리스트 내용
- toString 오버라이드할 때 다음 두 코드의 효율성 차이를 고려할 것
String str = "";
for(int i=0; i<1000000; i++) {
?? str = str + "a ";
}
return str;?
StringBuffer str = new StringBuffer("");
for(int i=0; i<1000000; i++) {
?? str.append("a ");
}
return str.toString();?
?
- 실행 예
hw5_1 : 홍길동
[20, 30, 20, 40, -999, 50, 90, 10]
리스트 크기 = 8
조회할 인덱스 입력: 7
인덱스 7의 원소 = 555
777로 갱신할 인덱스 입력: 0
[777, 30, 20, 40, -999, 50, 90, 10]
999를 삽입할 인덱스 입력: 2
[777, 30, 999, 20, 40, -999, 50, 90, 10]
삭제할 인덱스 입력: 5
인덱스 5의 원소 = -999
[777, 30, 999, 20, 40, 50, 90, 10]
// 여기부터는 (옵션1) 출력임
용량 증가 10-->20
용량 증가 20-->40
[777, 30, 999, 20, 40, 50, 90, 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]
----------------------------------------------------------
목적
- 순차자료구조 구현을 연습한다.
----------------------------------------------------------
유의사항
- 적절한 comment
//***************************
// 파일명: ... .java
// 작성자: ...
// 작성일: ...
// 설명:...
//***************************
- 들여쓰기
- 식별자 이름을 자바 관례에 맞게 적절히 붙일 것
- command-line에서 java -jar 과제코드.jar 로 채점합니다. 철자도 똑같게 이 명령이 제대로 실행되어야 합니다.
- 과제코드와 본인의 이름을 맨 처음 출력
과제1 -> 과제2 연결된 과제라서
package first;
import java.util.Scanner;
public class Driver {
public static void main(String[] args) {
// TODO Auto-generated method stub
MyList list = new MyList();
list.add(20);
list.add(30);
list.add(20);
list.add(40);
list.add(-999);
list.add(50);
list.add(90);
list.add(10);
System.out.println(list);
System.out.println("리스트의 크기" + list.size());
Scanner scn = new Scanner(System.in);
System.out.println("조회할 인덱스 입력 : "); //7
int index1 = scn.nextInt();
System.out.println("인덱스 7의 원소 : "+ list.get(index1));
System.out.println("777로 갱신할 인덱스 입력 : "); //0
int index2 = scn.nextInt();
list.set(index2, 777);
System.out.println(list);
System.out.println("999로 삽입할 인덱스 입력 : "); //2
int index3 = scn.nextInt();
list.add(index3, 999);
System.out.println(list);
System.out.println("삭제할 인덱스 입력 : "); //5
int index4 = scn.nextInt();
int removedvalue = list.remove(index4);
System.out.println("인덱스"+index4+"의 원소 : "+removedvalue);
System.out.println(list);
System.out.println("*********** (옵션1) ***********");
list.add(10,10);
System.out.println(list);
list.add(20,10);
System.out.println(list);
}
}
class MyList {
private int[] value= new int[10];
private int cnt = 0;
public MyList() {
// TODO Auto-generated method stub
super();
}
public int get(int index){
if(this.value[index]==0){
try {
Exception e = new Exception("고의로 발생시켰음.");
throw e;
} catch (Exception e) {
System.out.println("에러 메시지 : " + e.getMessage());
e.printStackTrace();
}
System.out.println("프로그램이 정상 종료되었음.");
}
int result = this.value[index];
return result;
}
public void set(int index, int integer){
if(this.value[index]==0){
try {
Exception e = new Exception("고의로 발생시켰음.");
throw e;
} catch (Exception e) {
System.out.println("에러 메시지 : " + e.getMessage());
e.printStackTrace();
}
System.out.println("프로그램이 정상 종료되었음.");
}
this.value[index]=integer;
}
public void add(int index, int integer){
int plus =1;
if(index>9){
int[] value2 = new int[this.value.length*2];
for (int j = 0; j < this.value.length; j++) {
value2[j] = this.value[j];
}
this.value = value2;
this.value[index] = integer;
for(int i = 10; i<this.value.length;i++){
this.value[i] = plus;
++plus;
if(plus==26){
break;
}
}
System.out.println("용량 증가"+ this.value.length+" 에서"+(this.value.length*2));
}else{
if(this.value[index]!=0){
for(int i =this.cnt; i>index;i--){
if(this.value[i]==0){
this.value[i]= this.value[i-1];
this.value[i-1]=0;
}
}
}
this.value[index] = integer;
this.cnt +=1;
}
}
public int remove(int index){
if(this.value[index]==0){
try {
Exception e = new Exception("고의로 발생시켰음.");
throw e;
} catch (Exception e) {
System.out.println("에러 메시지 : " + e.getMessage());
e.printStackTrace();
}
System.out.println("프로그램이 정상 종료되었음.");
}
int temp = this.value[index];
this.value[index]=0;
this.cnt -=1;
for(int i = 0; i<this.value.length-1; i++){
if(this.value[i]==0&&this.value[i+1]!=0){
this.value[i] = this.value[i+1];
this.value[i+1] = 0;
}
}
return temp;
}
@Override
public String toString() {
String result="";
if(this.value[0]==0){
result ="[]";
System.out.println(result);
}else{
result ="[";
for(int i =0; i<value.length;i++){
if(this.value[i]!=0){
result += value[i]+","+" ";
}
}
result = result.substring(0, result.length()-2);
result += "]";
}
return result;
// return "MyList [value=" + Arrays.toString(this.value) + ", cnt=" + cnt + "]";
}
public void print(){
if(this.value[0]==0){
String result ="[]";
System.out.println(result);
}else{
String result ="[";
for(int i =0; i<value.length;i++){
if(this.value[i]!=0){
result += value[i]+","+" ";
}
}
result = result.substring(0, result.length()-2);
result += "]";
System.out.println(result);
}
}
public void add(int a){
int plus =1;
if(cnt>=10){
int[] value2 = new int[this.value.length*2];
for (int j = 0; j < this.value.length; j++) {
value2[j] = this.value[j];
}
this.value = value2;
for(int i =0; i<this.value.length; i++){
if(this.value[i]==0){
this.value[i]=a;
this.cnt +=1;
break;
}
}
for(int i = 10; i<this.value.length;i++){
this.value[i] = plus;
++plus;
if(plus==26){
break;
}
}
System.out.println("용량" + this.value.length+"에서"+(this.value.length*2));
}else{
for(int i =0; i<this.value.length; i++){
if(this.value[i]==0){
this.value[i]=a;
this.cnt +=1;
break;
}
}
}
}
public int size() {
int count =0;
for(int i=0; i<this.value.length; i++){
if(this.value[i]==0){
count+=1;
}
}
this.cnt = this.value.length - count;
return this.cnt;
}
}
댓글
댓글 쓰기