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

3주차과제입니당. #79

Open
wants to merge 1 commit into
base: youyeonyou
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
34 changes: 34 additions & 0 deletions Homework1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import java.util.Scanner;

public class Homework1 {
public static void main(String[] args) {
Copy link
Member

Choose a reason for hiding this comment

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

Car의 정보(name, speed)를 담고있는 Car 클래스를 선언해주세요. 그에 맞추어 코드를 수정해주세요.

Copy link
Author

Choose a reason for hiding this comment

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

음,,,,


int count;
int[] num;
String[] name;

Scanner sc = new Scanner(System.in);
System.out.println("자동차의 갯수를 입력하세요");
count = sc.nextInt();
num = new int[count];
name = new String[count];

for(int i=0;i<count;i++) {

System.out.println( i+1 +"번 째 자동차의 스피드를 입력하세요.");
num[i] = sc.nextInt();

System.out.println(i+1 +"번 째 자동차의 이름을 입력하세요");
name[i] = sc.next();

}

System.out.println("-----경기 참가자 소개-----");

for(int j=0;j<count;j++) {
System.out.println("스피드는 " + num[j] + "이고," + " 이름은 " + name[j] +"입니다." );
}

}

}