Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: pls help me out on this (import scanner)

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default pls help me out on this (import scanner)

    Am a beginner and am learning on my own
    i started two days ago and am getting on fine

    but i have a problem now, some should pls help out


    i started with JAVA somedays ago and i think am getting well on it
    But the problem i have now is that some of the code written on the material are somehow different wen i work on java IDE

    package javaapplication2;

    public class main {

    public static void main(String[] args) {


    int firstnumber, secondnumber, thirdnumber, answer;
    firstnumber = 100;
    secondnumber = 75;
    thirdnumber = 25;

    answer = (firstnumber * secondnumber) / thirdnumber;

    System.out.print("Total is " + answer);

    you can see above that there is no In and Run was successfull

    But the material says printIn. y is that so cos its confusing
    ----------------------------------------------------------------------------------------------------


    another one now is

    package javaapplication5;

    public class JavaApplication5 {


    import java.util.Scanner;

    public static void main(String[] args) {



    String firstname;
    System.out.print("Enter Your First Name Here"wink;
    firstname = user_input.next();

    String secondname;
    System.out.print("Enter Your Family Name Here"wink;
    secondname = user_input.next();

    String fullname;
    fullname = (firstname + " " + secondname);

    System.out.print("You are" + fullname);

    java is telling that there is error on the bolded
    can someone pls help out


    yahoo
    facebook
    google
    skype
    whatsapp

    but google and skype will be better
    i dont want pple disturbing me on FB

    pls PM and i will send my id
    Thanks

    I cant do it alone


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: pls help me out on this (import scanner)

    System.out.print("Total is " + answer);
    you can see above that there is no In and Run was successfull
    It isnt IN as you believe, but LN, short for line (see: println).
    The difference is that println ends the string with a new line character, whereas print does not.

    For your second issue, you never defined "user_input" anywhere. Before you use it, you need to say Scanner user_input = new Scanner(System.in);
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. The Following User Says Thank You to newbie For This Useful Post:

    dokunbam (October 5th, 2013)

  4. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: pls help me out on this (import scanner)

    Working the problem right here in the forum is fine. That's what it's for.

    Read the Announcement topic at the top of the sub-forum to learn how to post code in code or format tags. Post the code causing the error and the EXACT error message/stack trace, copied and pasted from just as it appears in your terminal. Telling us "there is error" is not helpful, at least not as helpful as you could be.

  5. The Following User Says Thank You to GregBrannon For This Useful Post:

    dokunbam (October 5th, 2013)

  6. #4
    Junior Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: pls help me out on this (import scanner)

    ok thanks

    --- Update ---

    for the scanner i have that in place immediately after
    public class void main(string[] args) {

    still have error (something like a small bulb and a red dot on that line

    then on the import java.util.Scanner; (line i have something like a red caution mark there)


    do i need to delete the comments?

    thanks

  7. #5
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: pls help me out on this (import scanner)

    import java.util.Scanner; needs to be above public class JavaApplication5 and under package javaapplication5;.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  8. #6
    Junior Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: pls help me out on this (import scanner)

    thanks guys i have got it and its working perfectly now
    then i will move on to JAVA OPTION PANES

Similar Threads

  1. [SOLVED] String Import
    By OceansRythme in forum Object Oriented Programming
    Replies: 4
    Last Post: September 17th, 2013, 12:37 PM
  2. [SOLVED] Which is more efficient? "import java.package.subpackage" or "import java.package.*"
    By Andrew R in forum Java Theory & Questions
    Replies: 1
    Last Post: August 18th, 2013, 01:11 PM
  3. Import if Import is Found, Else
    By blazedGinger in forum Java Theory & Questions
    Replies: 5
    Last Post: March 9th, 2013, 06:43 PM
  4. from where i should import
    By javaking in forum Java SE APIs
    Replies: 0
    Last Post: April 12th, 2010, 07:51 AM
  5. [SOLVED] Do i need to import anything here?
    By straw in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 6th, 2010, 06:42 PM