Results 1 to 4 of 4
  1. #1
    silvia is offline Member
    Join Date
    Jul 2007
    Posts
    35
    Rep Power
    0

    Default I can't figure this out

    I Write an application that calculates the prduct of the odd integers from 1 to 15.
    That is all it says...does it mean multiply all the odd numbers from 1 to 15? If so how do i do this....im not sure how to point out negative numbers.
    Thanks

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Are worried about multiplying negative odd numbers?

    int can hold negative numbers at all.

  3. #3
    cruxblack is offline Senior Member
    Join Date
    Jul 2007
    Posts
    130
    Rep Power
    0

    Default

    calculates da products of odd numbers from 1-15?

    products in da mathematical terms of multiplication u mean rite?
    so i supposed u want to make it like this?

    1x3x5x7x9x11x13x15 = ?

    if u wanna get da odd number from 1 - 15, u could use da modulus operator %, a loop, and an if logical statement

    da main method should look like this inside i think

    Java Code:
        int x = 1;
        for(int i=1;i<=15;i++)
        {
            if((i%2)==1)//meaning that its an odd number
            {
                x = i*x;//or u could just write it x*=i to make it short, but its not really a good idea if ur still stufying, itll give u some hard time reading n doin ur logic
            }
        }
    btw, just in case it didn't work, make sure u put da code inside da main method k, i already tested da code n it run out just fine :D

    logic comes first, coding comes later :p
    hope this helps sylvia:D

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Design comes first.:p


    Quote Originally Posted by cruxblack View Post
    logic comes first, coding comes later :p

Similar Threads

  1. Java assignment - couple methods don't know how to figure out
    By Snowboardmylife in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 10:52 AM
  2. Replies: 3
    Last Post: 12-25-2007, 04:10 AM
  3. Seems so simple yet I can't figure it out!
    By adamhaviland in forum New To Java
    Replies: 1
    Last Post: 11-03-2007, 06:26 PM

Posting Permissions

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