Predatawr
07-25-2004, 11:45 AM
hey, this forum looks really great and im frustrated that i didn't find it sooner, especially since my computer science course is coming to an end soon :(
I have a problem, i have to write a database for a soccer team that can store information on players/teams. I will include a layout, and show u the code i have done now, problem is i don't know anything about storing it all as an array/database.
-----------------------------------------------------------------------
import java.io.*;
import java.util.*;
import javax.swing.*;
public class myTeam
{
public static void main(String[]args)
{
int team, score, howMany;
String teams, scores, enterTeam, enterHowMany;
enterHowMany = JOptionPane.showInputDialog("How many teams are there?");
howMany = Integer.parseInt(enterHowMany);
String[]teamlist = new String[howMany];
int[]goals = new int[howMany];
for (int i=0; i<howMany; i++)
{
enterTeam = JOptionPane.showInputDialog("Please enter the name of the team");
teamlist[i]=enterTeam;
}
for (int i=0; i<howMany; i++)
{
System.out.println(teamlist[i]);
}
for (int i=0; i<howMany; i++ )
{
scores = JOptionPane.showInputDialog("How many goals did " + teamlist[i] + " score?");
score = Integer.parseInt(scores);
goals[i]=score;
}
System.out.println("Thankyou");
System.out.println("All scores taken");
System.out.println("---------------------");
for (int i=0; i<howMany; i++)
{
System.out.println(teamlist[i] + " scored " + goals[i] + " goals");
}
System.out.println("---------------------");
try
{
FileOutputStream teamlistOut = new FileOutputStream("C:/ladder.txt");
PrintWriter print = new PrintWriter(teamlistOut);
for (int i=0; i<howMany; i++)
{
print.println(teamlist[i] + " scored " + goals[i] + " goals");
}
print.close();
}catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
------------------------------------------------------------------
This is still complete as is, i haven't got search functions or anything added to it, nor modifying functions and so on. Im pretty noob at programming, as it was i got alot of help to even get that much (above).
I'd appreciate help greatly as this assignment is due very soon and eh, it looks like im heading nowhere :(
I have a problem, i have to write a database for a soccer team that can store information on players/teams. I will include a layout, and show u the code i have done now, problem is i don't know anything about storing it all as an array/database.
-----------------------------------------------------------------------
import java.io.*;
import java.util.*;
import javax.swing.*;
public class myTeam
{
public static void main(String[]args)
{
int team, score, howMany;
String teams, scores, enterTeam, enterHowMany;
enterHowMany = JOptionPane.showInputDialog("How many teams are there?");
howMany = Integer.parseInt(enterHowMany);
String[]teamlist = new String[howMany];
int[]goals = new int[howMany];
for (int i=0; i<howMany; i++)
{
enterTeam = JOptionPane.showInputDialog("Please enter the name of the team");
teamlist[i]=enterTeam;
}
for (int i=0; i<howMany; i++)
{
System.out.println(teamlist[i]);
}
for (int i=0; i<howMany; i++ )
{
scores = JOptionPane.showInputDialog("How many goals did " + teamlist[i] + " score?");
score = Integer.parseInt(scores);
goals[i]=score;
}
System.out.println("Thankyou");
System.out.println("All scores taken");
System.out.println("---------------------");
for (int i=0; i<howMany; i++)
{
System.out.println(teamlist[i] + " scored " + goals[i] + " goals");
}
System.out.println("---------------------");
try
{
FileOutputStream teamlistOut = new FileOutputStream("C:/ladder.txt");
PrintWriter print = new PrintWriter(teamlistOut);
for (int i=0; i<howMany; i++)
{
print.println(teamlist[i] + " scored " + goals[i] + " goals");
}
print.close();
}catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
------------------------------------------------------------------
This is still complete as is, i haven't got search functions or anything added to it, nor modifying functions and so on. Im pretty noob at programming, as it was i got alot of help to even get that much (above).
I'd appreciate help greatly as this assignment is due very soon and eh, it looks like im heading nowhere :(