text파일에 있는 거 읽어와서 input파일에 있는거에 따라서 score 계산해서 높은 팀을 결과로 내놔야하는데..
-----------------------------------
bowling.txt(input file)
<member><Team><score>
Fred Blue 20
Harry Blue 35
Tony White 43
Hilda Blue 92
Paul White 34
Tom White 20
output이
winning team : White
Tony : 43
Paul : 34
Tom : 20
이 나와야해요!!!! parallel array를 이용하라고 하는데 잘 모르겠어요...
다음은 기본적인 소스코드에요..
번호 밑에 step 별로 적어놓으면 되는데 잘 모르겠어요...
도와주세요 ㅠㅠㅠㅠ
--------------------------------------------------------------------------------------------------------------
import java.io.*;
import java.util.*;
// declaration of the class
public class Bowling
{
// declaration of main program
public static void main(String[] args) throws FileNotFoundException
{
// 1. connect to input file
Scanner fin = new Scanner(new FileReader("bowling.txt"));
// declare arrays below
String Team, Member;
int teamw, teamb, Score;
// 2) initialize array accumulators to zero
// 3) display a descriptive message
System.out.println(
"This program reads the lines from the file bowling.txt to determine\n"
+ "the winner of a bowling match. The winning team, members and scores\n"
+ "are displayed on the monitor.\n");
// 4) test Scanner.eof() condition
while (fin.hasNext())
{
// 5) attempt to input next line from file
Member = fin.next();
Team = fin.next();
Score = fin.nextInt();
// 6) test team color is blue
// 7) then store blue member and score
// 8) increase blue array accumulator
// 9) else store white member and score
// 10) increase white array accumulator
}
// 11) if blue team score is larger
// 12) then display blue team as winner
// 13) else display white team as winner
// 14 disconnect from the input file
fin.close();
}
// implement method sumArray() below
/* 1. initialize accumulator to 0
2. loop over initialized array indices
3. increase accumulator by indexed array element
4. return accumulator
*/
// implement method printArray() below
/* 1. display the team name as the winner
2. loop over initialized array indices
3. display member and score for that array index
*/
} // end of the class
댓글 0