Results 1 to 4 of 4
  1. #1
    ibrafiqb is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default Problem with calculation

    Hi, I am having problems with a code. Basically the code reads some information from a text file e.g:

    Liverpool : Bradford : 1 : 3
    Manchester : Chelsea : 4 : 5

    etc....

    It splits each bit down to four variables, so homeTeam, awayTeam, htScore & atScore. It has been programmed to count all the entries. At some point the program asks the user whether they would like to focus on all teams (as per the output above) or on a Specific team. So far if I put in a specific team i.e Liverpool, it calculates how many games Liverpool has played by using an if statement. However I need it to calculate how many games Liverpool or any other team depending on the team entered have won / lost etc etc. I am really struggling. I have posted the rest of the code underneath. Any suggestions guys? Thanks
    Last edited by ibrafiqb; 11-24-2010 at 05:04 PM. Reason: students googling and copying work

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default

    Please edit your article so that the angular brackets in your <code> tags are replaced by square brackets.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    ibrafiqb is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Please edit your article so that the angular brackets in your <code> tags are replaced by square brackets.

    kind regards,

    Jos
    Done for you, hope it helps! I have also uploaded the text file which the program will require to run... please use p for plain text at the moment only thanks.
    Attached Files Attached Files

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by ibrafiqb View Post
    Done for you, hope it helps! I have also uploaded the text file which the program will require to run... please use p for plain text at the moment only thanks.
    Thanks, now your code is more readable (it contains a lot of empty lines though); I'd build a little class first:

    Java Code:
    public class Match {
       private String home;
       private String visitors;
       private int pros;
       private int cons;
       public Match(String home, String visitors, int pros, int cons) {
          this.home= home;
          this.visitors= visitors;
          this.pros= pros;
          this.cons= cons;
       }
       // rest of the code goes here, e.g. getters 
    }
    I'd also keep a Map<String, List<Match>> where the key represents the home team and the value, a List of Matches, represents all the matches where the key is the home team. Then I'd think a bit more before I'd code the rest ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Calculation with char
    By chuckbalzer in forum New To Java
    Replies: 7
    Last Post: 09-20-2010, 05:29 PM
  2. Need help with doing a calculation in Java
    By John D. in forum New To Java
    Replies: 6
    Last Post: 02-24-2009, 11:44 PM
  3. Two problem for my rssi calculation program
    By iamchoilan in forum Java 2D
    Replies: 12
    Last Post: 04-27-2008, 07:56 PM
  4. Two problem for my rssi calculation program
    By iamchoilan in forum Advanced Java
    Replies: 3
    Last Post: 04-25-2008, 03:49 PM
  5. Problem with Calculation ....
    By danny000 in forum New To Java
    Replies: 1
    Last Post: 04-15-2008, 02:42 PM

Posting Permissions

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