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 12 of 12

Thread: Some simple help please!

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Some simple help please!

    Some background... this is my second week in java and so far its going great in my comp sci class, but some of the eIMACS labs are killing me.



    In the following code segment, a and b are non-negative doubles. Write code that assigns to b the result of rounding a to one decimal place.

    // Enter a value to test here
    double a = ;
    double b;

    // Enter your code here

    I have tried to use Math.round(a,1); to round to one decimal place, its not working and i have no idea how to do it any other way, any help will be great.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Some simple help please!

    its not working
    Can you post the code you executed and its output that shows the problem.
    Last edited by Norm; September 6th, 2012 at 07:57 PM.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Some simple help please!

    // Enter a value to test here
    double a =6.05000001 ;
    double b;

    // Enter your code here
    b = Math.round(a,1);

    After running this error occurs:

    TC1.java:16: cannot find symbol

    symbol : method round(double,int)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Some simple help please!

    cannot find symbol
    That says the compiler can not find a definition for a round method with the args of double and int.
    Where did you see that method defined? Do you have the correct import statement to tell the compiler where the method is defined?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Some simple help please!

    um, i did not add a import statement b/c i assumed the complier in eimacs already had that. I would need to use
    import java.lang.Math;
    right?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Some simple help please!

    Where is the method defined that you are trying to use? Where did you see doc for how to code it?

    EDIT: Sorry, I don't know anything about eimacs.
    Last edited by Norm; September 6th, 2012 at 08:14 PM.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Some simple help please!

    Um i.. don't know.

    This might help, its all i'm really given
    Capture.jpg

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Some simple help please!

    Do you know where the Java SE packages and classes and their methods are defined? You need to have a link to the site where the API doc is:
    Java Platform SE 7

    Instead of making up method names and their args, go to the API doc and find one that will work.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Sep 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Some simple help please!

    Ok, ill try and find one that works.

    Thanks for the help.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Some simple help please!

    What has been discussed in your class so far? What techniques have you been shown?
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Some simple help please!

    Kind of old, and kind of a stupid way to do it but here you go.
    ...
    Last edited by copeg; June 7th, 2013 at 12:22 PM. Reason: Removed spoonfeeding

  12. #12
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Some simple help please!

    firecool67, welcome to the forums. Please read the following:
    Announcements - What's Wrong With My Code?
    http://www.javaprogrammingforums.com...n-feeding.html

Similar Threads

  1. Simple Shopping Cart..... not so simple
    By jpsider in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 20th, 2012, 02:18 PM
  2. Simple I/O Question...well could be simple for you?
    By basketball8533 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 30th, 2011, 06:44 AM
  3. [SOLVED] Should be simple.
    By Time in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 22nd, 2010, 02:23 AM
  4. urgent simple help for a very simple program
    By albukhari87 in forum Java Applets
    Replies: 4
    Last Post: June 5th, 2010, 03:43 PM
  5. not so simple, simple swing question box
    By wolfgar in forum AWT / Java Swing
    Replies: 2
    Last Post: November 20th, 2009, 03:47 AM