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,
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 :(
x
Re: Slight problem with fraction calculator code
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.