Can someone help me figure out what I am doing wrong here. I think I may be running my head into this way to many times to see what is wrong with it. The error code is posted below.
import java.util.Scanner;
public class userName {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
getNames(firstName, lastName);
userPassword(firstName, lastName);//function call
}
public static void getNames(String firstName, String lastName){
Scanner kbd = new Scanner(System.in);//Creates new scanner
System.out.println("Please enter your first and middle names.");//prompts user for input
firstName = kbd.nextLine();//first and middle names are entered here
System.out.println("Please enter your last name.");//prompts user for input
lastName = kbd.nextLine();//last name is entered here
}
public static void userPassword(String firstName, String lastName){
int x = 1;//used to print out the first letter of the first name
int y = 4;//used to print out the first four letters of the last name
//System.out.println("Your first and middle names are " + firstName);//test to see if firstName was passed correctly
//System.out.println(firstName.substring(0,x));//test to see if the print out is abbreviated
//System.out.println("Your last name is " + lastName);//test to see if lastName was passed correctly
//System.out.println(lastName.substring(0,y));//test to see if the print out is abbreviated
System.out.println("Your user password is " + firstName.substring(0,x) + lastName.substring(0,y));
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
firstName cannot be resolved to a variable
lastName cannot be resolved to a variable
firstName cannot be resolved to a variable
lastName cannot be resolved to a variable