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

Thread: Homework Help - Conductors & Methods

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

    Default Homework Help - Conductors & Methods

    Hi:

    I'm in a Java online course. I am completely lost on a homework problem and cannot proceed, since I don't have my Java textbood to refer off of anymore (accidentally left it in another state). Any suggestions on how to start? I can't seem to find any help online. Here is the problem.

    ------------------------------------------------------------------------------------------------------------------------

    Write and fully test a class that represents rational numbers. A rational number can be represented as the ratio of two integer values, ( a ) and ( b ), where ( b ) is not zero. The class has attributes for the numerator and denominator of this ratio. The ratio should always be stored in its simplest form. That is, any common factor of ( a ) and ( b ) should be removed. For example, the rational number 40/12 should be stored as 10/3.

    The class has the following contructors and methods:

    * A default constructor that sets the rational numbers to 0/1
    * A constructor that has parameters for the numerator and denominator and converts the resulting ratio to simplified form.
    * simplify--a private method that converts the rational numbers to simplified form.
    * geGCD (x, y )--a private static method that returns the largest common factor of the two positive integers x and y, that is, their greatest common divisor. For example, the greatest common divisor of 40 and 12 is 4.
    * getValue--returns the rational number as a double value.
    * toString--returns the rational number as a string in the form a/b.

    ------------------------------------------------------------------------------------------------------------------------

    //Here is what I currently have... like I said, it's hard for me to proceed without my book. How would I even begin? I am completely lost. Much help is appreciated!!

    import java.util.Scanner;
    public class rational
    {


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,462
    My Mood
    Hungover
    Thanks
    144
    Thanked 639 Times in 547 Posts

    Default Re: Homework Help - Conductors & Methods

    First off, it's constructor, not conductor. And secondly, who needs a textbook when you have the tutorials? The Java™ Tutorials
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Homework Help - Conductors & Methods

    First, thanks to KevinWorkman for an excellent link. A favorite reference of mine.

    Second, please see the announcements page for the use of code tags and other forum tips.

    I think with a choice of the many search engines, and keywords "java hello world" you can get a bit more code than provided in the op.

Similar Threads

  1. HELP WITH HOMEWORK!!
    By jmillernc01 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 10th, 2012, 11:13 AM
  2. Homework help
    By hockey15 in forum Object Oriented Programming
    Replies: 3
    Last Post: September 23rd, 2012, 11:28 PM
  3. Why and where abstract methods & classes and static methods are used?
    By ajaysharma in forum Object Oriented Programming
    Replies: 7
    Last Post: July 14th, 2012, 01:16 AM
  4. Homework help
    By cd247 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 11th, 2009, 05:56 PM
  5. need help with homework!
    By programmer12345 in forum Java Theory & Questions
    Replies: 2
    Last Post: September 27th, 2009, 05:34 AM

Tags for this Thread