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??
Code :
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??
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?
Re: Whats wrong with my code!!
Quote:
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