Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Whats wrong with my code!!

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    29
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Exclamation Whats wrong with my code!!

    Okay so im working on a project and im using instance variables and two dimensional arrays
    and i see nothing wrong what iv done so far can anyone see what is wrong??

    import java.awt.*;
    import hsa.Console;
    import java.io.*;
    import java.text.*;
    import java.util.Random;
    public class Basketball
    /*
    *Module 14 Assignment
    *July 21 2011
    */
    {   
      static Console c = new Console ();
      public static int x, i, names, choice, smallest;
      public static String player[][] = new String[1001][7];
      public static String temp;
      public static void main (String[] args)
     
       { 
         do
            {
                //MENU
                c.print("Main Menu");
                c.print("\n1. Enter Player Data");
                c.print("\n2. Show Data by name");
                c.print("\n3. Show data by stats");
                c.print("\n4. Search Players");
                c.print("\n5. Modify Player");
                c.print("\n6. Delete Player");
                c.print("\n7. End Program\n");
                c.print("Please enter a choice (1-7)\n");
                choice = c.readInt();
                if ((choice < 1) || (choice > 7))
                c.print ("\nPlease choose a number between 1-7 only");
                if (choice == 1) enterdata();
                if (choice == 2) showname();
                if (choice == 3) shownum();
                if (choice == 4) search();
                if (choice == 5) modify();
                if (choice == 6) delete();
             }
             while ((choice < 1) || (choice > 7)) ;
       }
     
      //Option 1  
      public static void enterdata()
      {
            c.clear();
            c.print("You have selected to input player data\n");
            c.print("How many players are you going to input?\n");
            names = c.readInt();
            for (x=0;x<=names;x++)
            {
                c.print("What is the players first name?\n");
                player [x][0] = c.readLine();
                c.print("What is the players last name?\n");
                player [x][1] = c.readLine();
                c.print("What position does this player play?\n");
                player [x][2] = c.readLine();
                c.print("What is the players height?\n");
                player [x][3] = c.readLine();
                c.print("What is the players weight?\n");
                player [x][4] = c.readLine();
                c.print("How many points has the player made?\n");
                player [x][5] = c.readLine();
                c.print("How many blocks has the player made?\n");
                player [x][6] = c.readLine();
                c.print("How many steals has the player made?\n");
                player [x][7] = c.readLine();
            }
      }

    There is more to the code, this is just the part that i think is wrong
    any suggestions??


  2. #2
    Junior Member
    Join Date
    Jul 2011
    Posts
    29
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Re: Whats wrong with my code!!

    Okay i was able to fix this problem, but how do i make it so that after this finishes it shows the menu again?

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Whats wrong with my code!!

    how do i make it so that after this finishes it shows the menu again?
    Put the code inside of a loop with the menu at the top and the "this" at the bottom

Similar Threads

  1. Can't seem to understand whats wrong with my code! Help!!
    By aquir in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 2nd, 2011, 12:06 PM
  2. Whats Wrong with this code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2011, 10:59 PM
  3. Whats wrong with my code?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 4th, 2011, 05:34 PM
  4. Whats wrong with my code?
    By mlan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 27th, 2010, 01:42 PM
  5. i'm new to java. whats is wrong in this code?
    By igorek83 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 30th, 2009, 08:38 PM