Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Im dying lol - Database Prob

    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
    Attached Files Attached Files

  • #2
    New Coder
    Join Date
    Jul 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've been thinking im not going to add anything about teams, just which team they're in, and focus mainly on the goal aspect of it .. since Im really getting ahead of myself... I also don't know how to add previous scores to new - modifying as such

  • #3
    New Coder
    Join Date
    Jul 2004
    Location
    Bombay, India
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you have to use Java? MySQL will make your life much,much easier
    "What, me worry?"

  • #4
    New Coder
    Join Date
    Jul 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by TheSeeker
    Do you have to use Java? MySQL will make your life much,much easier
    Yea i HAVE to use java


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •