Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By JosAH

Thread: Short java programming, need help ASAP

  1. #1
    j@y
    j@y is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Short java programming, need help ASAP

    So, the deal is I've got finals this week, and three tests in one day tomorrow, and I fell asleep at around 2 o clock in the morning, before I got around to trying my hand at writing these methods. I wouldn't ask for help unless I was desperate, so I ask that I can get some help with these two short programming tasks.

    1. Write a method that will iteratively determine and return the Greatest Common Factor of two integers.

    2. Write a method that will iteratively determine and return the factorial of an integer. (i.e. 5! = 5 * 4 * 3 * 2 * 1)

  2. #2
    FallenBlade is offline Member
    Join Date
    Mar 2010
    Posts
    31
    Rep Power
    0

    Default Re: Short java programming, need help ASAP

    Sorry friend, we can only help with specific errors in your code. Please attempt to write it yourself and if you have problems with specific areas we'd be happy to help.

  3. #3
    j@y
    j@y is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: Short java programming, need help ASAP

    Ah, here's my attempt at it then:

    public static int gcd(int a, int b)
    {
    if (b==0) return a;
    esle
    return gcd(b, a%b);
    }

    Will that work? Please help.

  4. #4
    FallenBlade is offline Member
    Join Date
    Mar 2010
    Posts
    31
    Rep Power
    0

    Default Re: Short java programming, need help ASAP

    Have you tried running it? Does it return what you would expect?

  5. #5
    j@y
    j@y is offline Member
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    0

    Default Re: Short java programming, need help ASAP

    No I haven't, when I go to External tools and try to run it, my programs never works and I can't.

  6. #6
    FallenBlade is offline Member
    Join Date
    Mar 2010
    Posts
    31
    Rep Power
    0

    Default Re: Short java programming, need help ASAP

    What IDE are you using? Is that all the code you have written?

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Short java programming, need help ASAP

    The order of things is to first study the material and then apply it. I suggest that you hit the basic Java tutorials first and study the information there, and afterwords only then try to create a program. You can't make this stuff up and the compiler is very picky.

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default Re: Short java programming, need help ASAP

    Quote Originally Posted by j@y View Post
    Ah, here's my attempt at it then:

    public static int gcd(int a, int b)
    {
    if (b==0) return a;
    esle
    return gcd(b, a%b);
    }

    Will that work? Please help.
    Don't just copy and paste code from the internet; try to understand how the algorithm works first; next try to implement the algorithm and finally, if you're stuck, come back here, but don't try to smuggle yourself through this assignment.

    kind regards,

    Jos
    Fubarable likes this.
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. short message service (SMS in java)
    By ashin in forum Advanced Java
    Replies: 4
    Last Post: 06-04-2011, 07:59 AM
  2. Java Balancing Tree, please help right away ASAP !!!!
    By Jumanji245 in forum New To Java
    Replies: 2
    Last Post: 05-31-2011, 12:27 AM
  3. A java program to print short form of a name.
    By Neeer in forum New To Java
    Replies: 2
    Last Post: 03-20-2011, 06:16 AM
  4. Replies: 3
    Last Post: 02-20-2011, 12:15 PM
  5. Need Java Help ASAP
    By L-dog in forum New To Java
    Replies: 22
    Last Post: 10-02-2008, 11:54 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
  •