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

Thread: Need help on mutliple class program.

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

    Default Need help on mutliple class program.

    This is my code so far and I have 1 error popping up on me.

    Am I doing anything wrong.

    import java.util.Scanner;
     
    public class JavaTheHut_MutlipleClass
    {
        private int number;
     
        public JavaTheHut_MultipleClass ()
        {
            System.out.println ("Welcome to the MultipleClass object!");
        }
     
        public void getNumber ()
        {
            Scanner input = new Scanner (System.in);
     
            System.out.print ("Please enter a non-negative, integer whole value: ");
            number = input.nextInt();
     
        }
     
        public void displayResults ()
        {
            System.out.printf ("%d: ", number);
        }
     
        public boolean isEven ()
        {
            if (number % 2 == 0)
     
                System.out.printf("%d=EVEN\n" , number);
     
            else
     
                System.out.printf("%d=ODD\n" , number);
        }
     
        public boolean isMultiple ()
        {
            if (number % 13 == 0)
     
                System.out.printf("%d=MULTIPLE\n" , number);
     
            else
     
                System.out.print("%d=NOT\n" , number);
        }
    }

    This is my error:

    JavaTheHut_MultipleClass.java:27: error: invalid method declaration; return type required
    public JavaTheHut_MultipleClass ()
    ^
    1 error


    This is what my outcome should look like using the code and its tester code:

    Welcome to the MultipleClass object!
    0:MULTIPLE:EVEN
    Please enter a non-negative, integer whole value: 39
    39:MULTIPLE:ODD

    This is my test code:

     
    public class JavaTheHut_MultipleClassTest
    {
        public static void main ( String args [] )
        {
            JavaTheHut_MultipleClass foo = new JavaTheHut_MultipleClass();
            foo.displayResults();
            foo.getNumber();
            foo.displayResults();
        }
    }
    Last edited by JavatheHut; September 24th, 2012 at 01:11 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,624
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Need help on mutliple class program.

    Check your spelling.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Two class program help
    By BuhRock in forum Object Oriented Programming
    Replies: 4
    Last Post: July 4th, 2012, 05:27 PM
  2. Need major help with a program for class
    By burnenator in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 20th, 2011, 09:55 PM
  3. Help with class program!!! STUCK! Program not doing what I Want!!!
    By sketch_flygirl in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 4th, 2011, 07:29 AM
  4. Class design for GUI program
    By albertkao in forum Object Oriented Programming
    Replies: 1
    Last Post: January 6th, 2011, 11:05 AM
  5. new program (lotto.class)
    By james137 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 3rd, 2009, 04:22 PM