Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

과제 입니다 #68

Open
wants to merge 6 commits into
base: yunho04
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions CarGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package JavaStudy;
import java.util.*;

public class CarGame {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Car 의 정보를 담는 Car 클래스를 따로 만들어주세요.

int number;
String [] name;
int [] speed;


public void introduce(){

System.out.println("자동차의 개수를 입력하세요");
Scanner sc = new Scanner(System.in);
number = sc.nextInt();
System.out.println(number);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용하지 않는 print문은 삭제해주세요.

String [] name = new String[number];
int [] speed = new int[number];

for(int i=1;i<=number;i++) {
System.out.println(i + "번째 자동차의 이름을 입력하세요");
name[i - 1] = sc.next();
System.out.println(i + "번째 자동차의 속도를 입력하세요");
speed[i - 1] = sc.nextInt();
}
System.out.println("-------------경기 참가자 소개------------------");
for(int x=1;x<=name.length; x++) {
System.out.println("스피드는" + speed[x - 1] + "이고, 이름은 " + name[x - 1] + "입니다");
}
}
public static void main(String[]args){
CarGame game= new CarGame();
game.introduce();
}

}