Java get user details

Posted by LC on Stack Overflow See other posts from Stack Overflow or by LC
Published on 2010-03-19T12:51:11Z Indexed on 2010/03/19 13:01 UTC
Read the original article Hit count: 360

Filed under:
|
|
|

I'm new to Java and I have to write a program to get user details which appear like this:


Author’s Details
****************
Name: J. Beans

YOB: 1969

Age: 41

Book Details

************

       Title: *Wonderful Java*
       ISBN: *978 0 470 10554 9*
       Publisher: *Wiley*

This is what I've done but it does not work, can anyone help me to find out the problem ?

import java.util.Scanner ;
public class UserDetails
{
public static void main(String args[])
{
    System scan = new Scanner(System.in);
    input sname, fname, born, title, isbn, publisher;
    System.out.print("Please enter author's surname:");
    sname = input.nextLine();
    System.out.print("Please the initial of author's first name:");
    fname = input.nextLine();
    System.out.print("Please enter the year the author was born:");
    born = input.nextLine();
    System.out.print("Please enter the author's book title:");
    title = input.nextLine();
    System.out.print("Please enter the book's ISBN:");
    isbn = input.nextLine();
    System.out.print("Please enter the publisher of the book:");
    publisher = input.nextLine;

    System.out.println("Author's detail");
    System.out.println("**********************");
    System.out.println("Name:" + fname + sname);
    System.out.println("YOB:" + born);
    System.out.println("Age" + born);
    System.out.println("Book Details");
    System.out.println("**********************");
    System.out.println("Title:" + "*" + title + "*");
    System.out.println("ISBN:" + "*" + isbn + "*");
    System.out.println("Publisher:" + "*" + publisher + "*");
  }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about user