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.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Slight problem with fraction calculator code

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Thanked 0 Times in 0 Posts

    Default Slight problem with fraction calculator code

    Hi, im new to Java but am ambitious to learn it. I have a slight problem with my code,

    public class Fraction1 {
        // ============================================================
        // Instance variables
        // ============================================================
         * The numerator of the fraction.
        private int numerator;
         * The denominator of the fraction.
        private int denominator;  
        // ============================================================
        // Constructors
        // ============================================================
         * Constructor which takes coefficients explicity.
         * Behaviour: Constructs a fraction with the specified numerator and
         *            denominator. Remember that your fraction should *always* be
         *            stored in irreducible form.
         * @param num   The numerator
         * @param denom The denominator
        public Fraction1(int num, int denom);
    	// Fill in this method
    	private static void main(String[] args) {
    	System.out.println("Enter numerator");
    	System.out.println("Enter demoninator");

    The error i get is 'missing method body or declare abstract', so after a little googl'ing i thought i'd removed the semi colon afer 'public Fraction1(int num, int denom);' but this gives me more errors, such as 'error ';' expected' and it expects a semi colon after the same line i just removed it from


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,517 Times in 2,468 Posts

    Default Re: Slight problem with fraction calculator code

    public Fraction1(
    Looks like a constructor for the class. See the tutorial for how to code a class's constructor:
    Providing Constructors for Your Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    When you get errors, copy the full text of the error message and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. I need help with my Netbeans calculator code
    By geto81 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 5th, 2012, 12:53 PM
  2. Help needed with calculator code
    By andys in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 21st, 2011, 08:02 PM
  3. [SOLVED] Another Calculator Problem
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 4th, 2010, 03:31 PM
  4. Mixed Fraction JAVA
    By x3iancute in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 19th, 2010, 09:18 PM