J
John
I have an employee class that needs name and age to be input from the
console, but I cannot control the cursor, which always go to the front of
the prompt line, making my program look not so professional.
Is there anyway that I can let it go to the end of the prompt?
public class employee
{
public employee() {
Scanner input = new Scanner( System.in );
System.out.println("Your name: ");
name = input.nextLine();
System.out.println("Your age: ");
age = input.nextLine();
}
..........................
private String name;
private String age;
}
Besides, I feel the constructor is ugly because I wonder whether there is
anyway to insert the prompt in the argmument parentheses? Any suggestion?
Thanks!
John
console, but I cannot control the cursor, which always go to the front of
the prompt line, making my program look not so professional.
Is there anyway that I can let it go to the end of the prompt?
public class employee
{
public employee() {
Scanner input = new Scanner( System.in );
System.out.println("Your name: ");
name = input.nextLine();
System.out.println("Your age: ");
age = input.nextLine();
}
..........................
private String name;
private String age;
}
Besides, I feel the constructor is ugly because I wonder whether there is
anyway to insert the prompt in the argmument parentheses? Any suggestion?
Thanks!
John