I've been asked to create a program where I make up 3 passwords for users. That's not the problem and I'm able to do that. My actual problem is the part where we must take these 3 designed passwords and place them inside a String array and then get it to loop through this array and display out the 3 different passwords. I really don't know how to go about from here and have been stuck on this. I've tried so many resources on this but still can't find anyone that can tell me what exactly to do in a case where the array values aren't pre-given.
import java.util.Scanner; import static java.lang.System.out; import java.io.*; public class BirdTag { public static void main (String args []) { Scanner myScanner= new Scanner (System.in); String ProvinceName,SpotterName,Surname; int Year=12 for (int i=0; i<3; i++) //I PLACE EVERYTHING IN HERE IN ORDER TO GET THE PROGRAM TO RUN 3 TIMES . I MIGHT BE WRONG HERE TOO. { out.println ("What is your province name, please enter E for Eastern Cape, N for Northern Cape and W for Western Cape"); ProvinceName = myScanner.nextLine (); out.println ("Province Name is " + ProvinceName); out.println ("Please enter your name"); SpotterName= myScanner.nextLine (); String Extract1= SpotterName.substring(0,2); out.println ("Name is " + Extract1); out.println ("enter your surname please "); Surname= myScanner.nextLine (); String Extract2=Surname.substring(0,2); out.println ("Surname is " + Extract2); String FinalPassword= ProvinceName+ Year+ Extract1+Extract2; out.print ("Your password is "); String Password = myScanner.nextLine(); //THIS IS THE PART WHERE EVERYTHING GOES WRONG AND I DON'T THINK I'M DOING THE RIGHT THING out.print (FinalPassword); out.println () ; String arrTags[] = new String[3];// THIS IS WHERE I TRY TO MAKE MY ARRAY BUT THEN FROM HERE ONWARDS I'M STUCK } } }
THANK YOU SO MUCH IN ADVANCE !