Hi I have a password generator and I have it mostly figured out. The only issue I am having is that when I print out my reversed string instead of printing the 2nd to last like I need. But it prints both of the last 2 letters of the first name. Here is the code:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("enter first name here: ");
String fname = input.next();
System.out.println("enter middle name here: ");
String mname = input.next();
System.out.println("Enter last name here: ");
String lname = input.next();
System.out.println("Enter birthday (MMDDYYYY) here: ");
int age = input.nextInt();
lname = lname.substring(lname.length()-3);
char resultfn = fname.charAt(1);
char resultmn = mname.charAt(2);
fname = fname.substring(fname.length()-2);
System.out.print(resultfn);
System.out.print(resultmn);
System.out.print(lname);
System.out.print(fname);
}
}