Results 1 to 4 of 4
  1. #1
    javanewbie101 is offline Member
    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    Default i've never used java before and i need help!!

    here is the description of what we have to do

    Write a Java program that perform the following:
    a. Prompts for userís first name.
    b. Prompts for userís last name.
    c. Prompts for userís age.
    The program should then display your full name (as last name, comma, first name), and age in days.

    here is what i have so far, and im getting an error

    import java.util.Scanner;

    public class PlusTest
    {

    public static void main (String[] args)
    {


    Scanner scan = new Scanner (System.in);

    System.out.println ("Enter your first name here:");

    mary = scan.nextLine();

    System.out.println ("You entered: \"" + mary+ "\"");

    its saying that it cannot find symbol for mary... i dont know what to do here.
    thanks for the help

  2. #2
    JavaAdviser is offline Member
    Join Date
    Sep 2012
    Posts
    26
    Rep Power
    0

    Default Re: i've never used java before and i need help!!

    You use a variable that has never been declared.

  3. #3
    thinkinjava24 is offline Member
    Join Date
    Sep 2012
    Posts
    17
    Rep Power
    0

    Default Re: i've never used java before and i need help!!

    import java.util.Scanner;

    public class PlusTest
    {

    public static void main (String[] args)
    {
    Scanner scan = new Scanner (System.in);

    System.out.println ("Enter your first name here:");

    String firstName = scan.nextLine();

    System.out.println ("Enter your last name here:");

    String lastName = scan.nextLine();

    System.out.println ("Enter your birthday here:");

    String birth = scan.nextLine();

    System.out.println ("Name : " + firstName + lastName);

    System.out.println ("Age : " + birth);
    }
    }

    you should assign the type to your variable. The code I give you is just the thing following your previous code.
    JAVA is a OOP language, generally, not all things happen in main.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: i've never used java before and i need help!!

    Please go through the Forum Rules -- particularly the third paragraph.
    Also the Guide For New Members and BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •