Ok i am kind of new to java, but I did google search for creating methods and got mixed results so i am a bit confused on how to achieve this..
Basically I have an array which will store 20 unique account numbers, no less no more.
In addition to storing the account number i will give the option to the user to store the account balance (money, yes u guessed it this is bank account kind of homework assignment)
So the issue that i am facing is, for the process of the program run time, if the user decides to add 15accounts, i want to know how can i put the consequent accno entry in to the next free array index . and also trigger a message to say no more accounts cannot be added after capping the number of accounts at 20
public static void addAccount()
{
int i=0;
String accno, input;
double accbal;
Scanner sc = new Scanner(System.in);
String[] accnums = new String[20];
System.out.print("Enter the account number:");
accno = sc.nextLine();
if(accno.length() != 9) //the accno shld not be more than 9.
{
System.out.println("Wrong accnum");
}
else
{
//THis is the part i am not sure how to put the code tks.
}
input= accnums[1];
System.out.println("The value:"+input);//this is just for me to display / test
}
Simplest (Though not most efficient, but I don’t believe it is an issue here) can be loop and look for a
null, and place it in the firstnullvalue: