Results 1 to 7 of 7

Thread: New to Java

  1. #1
    epic830 is offline Member
    Join Date
    Jan 2017
    Posts
    2
    Rep Power
    0

    Exclamation New to Java

    My assignment in my intro to java class is to make a program that will average 3 user enter numbers. I thought I had it down but I must be missing something!
    Attached Thumbnails Attached Thumbnails New to Java-screen-shot-2017-01-25-10.06.22-pm.png  

  2. #2
    asdfg is offline Senior Member
    Join Date
    Nov 2016
    Posts
    163
    Rep Power
    3

    Default Re: New to Java

    For every user input use new scanner.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: New to Java

    That's not how you concatenate Strings.
    Java Code:
    System.out.println("this is " + varOne + " how you " + varTwo + " it");
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: New to Java

    Quote Originally Posted by asdfg View Post
    For every user input use new scanner.
    A single Scanner is fine.
    There's no reason to use multiple ones.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    epic830 is offline Member
    Join Date
    Jan 2017
    Posts
    2
    Rep Power
    0

    Default Re: New to Java

    Quote Originally Posted by Tolls View Post
    A single Scanner is fine.
    There's no reason to use multiple ones.
    Thank you for your input! Yeah I did not think that multible scanners was neccisary or needed unless I was using multible methods of input. So I made the changes and It still will not run correctly. Any feedback?New to Java-screen-shot-2017-01-26-1.35.04-pm.png

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: New to Java

    Concatenation requires a + between every individual element in the print statement. You are missing some.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: New to Java

    There's no point running code that doesn't compile.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Posting Permissions

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