Friday, 13 September 2013

User input first and last name , print out intisials java eclipse

User input first and last name , print out intisials java eclipse

So , im having a piece of trouble here , tried with tutorials to fix it
but nothing really helped me out saw something about printout string 0,1
etc but didnt work eather.
What the program does atm : Asks user for first/last name and prints it
out first +last name
what i want it to do is print out the intisials of the users first and
last name, any ideas how to fix this? Please help , Thanks in advance!
My code looks like this atm
package com.example.sträng.main;
import java.util.Scanner;
public class Application {
public static void main(String[] args) {
String firstName,
lastName;
//Create scanner to obtain user input
Scanner scanner1 = new Scanner( System.in );
//obtain user input
System.out.print("Enter your first name: ");
firstName = scanner1.nextLine();
System.out.print("Enter your last name: ");
lastName = scanner1.nextLine();
//output information
System.out.print("Your first name is " + firstName + " and your
last name is "+ lastName);
}
}

No comments:

Post a Comment