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.

Page 2 of 2 FirstFirst 12
Results 26 to 36 of 36

Thread: Programming Exercise Help

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Exercise Help

    Look at the code that assigns a value to the variable: interest
    What happens to the value: (annualInterest/12) before it is assigned to interest?
    If you don't understand my answer, don't ignore it, ask a question.

  2. #27
    Junior Member
    Join Date
    Feb 2014
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Exercise Help

    It's stated as a int?

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Exercise Help

    What happens to 0.004 when it is converted to an int?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #29
    Junior Member
    Join Date
    Feb 2014
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Exercise Help

    Doesn't it round down to 0? So it has to be double?

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Exercise Help

    0.004 is a double and doesn't need to be cast to double.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #31
    Junior Member
    Join Date
    Feb 2014
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Exercise Help

    Okay, well I'm not sure what I'm suppose to see.

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Exercise Help

    I don't understand your last post. What does "suppose to see" mean?

    Do you know what is causing interest to be zero?
    Do you know how to change the code to keep interest from being zero?
    If you don't understand my answer, don't ignore it, ask a question.

  8. #33
    Junior Member
    Join Date
    Feb 2014
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Exercise Help

    No to both of those questions, sorry..

  9. #34
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Exercise Help

    What did you mean in post#29? "round down to 0"

    Do some experimenting with casting double values to int to see what happens. Write a short test program with this statement. Compile and execute it:
    System.println((int)4.3); //  see what cast to int does
    Change the 4.3 to different double values to see what happens
    If you don't understand my answer, don't ignore it, ask a question.

  10. #35
    Junior Member
    Join Date
    Feb 2014
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Programming Exercise Help

    No idea what to do man, sorry. I might just go skip this assignment.

  11. #36
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Programming Exercise Help

    Do you know how to write a small program for testing a statement?
    If you don't understand my answer, don't ignore it, ask a question.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. accessor and modifier method exercise; exercise 100
    By ghostheadx in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 30th, 2013, 10:18 PM
  2. Exercise 95 (I KNOW, I'm at an earlier exercise)
    By ghostheadx in forum What's Wrong With My Code?
    Replies: 9
    Last Post: December 24th, 2013, 08:42 PM
  3. Question about an exercise from D.S. Malik's Book "Java Programming"
    By Lahoree in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 15th, 2013, 01:47 AM
  4. Java Programming Exercise
    By Garron5899 in forum Loops & Control Statements
    Replies: 5
    Last Post: July 27th, 2012, 08:12 AM
  5. Need help with programming exercise.
    By X0BeachBabe0x in forum Loops & Control Statements
    Replies: 2
    Last Post: December 29th, 2011, 10:08 PM