Hi everyone,

Apparently I'm very bad at this whole programming thing, but, nevertheless, I am currently in a CPS course and in dire need of assistance!

I have 3 objects set up: TwoNumbers, TwoNumbersTester, and Test. When I build the code, it's all fine. When I run the code, though, I get the error shown in the title of this forum post.

Here is my code for TwoNumbers.java:

public class TwoNumbers extends Object                                           // Class header
{
   private double number1;                                                       // Instance variables
   private double number2;
   
      public TwoNumbers( double n1 , double n2 )                                 // Constructor method
      {
      	 number1 = n1;
      	 number2 = n2;
      } 
    
      public void setNums( double n1 , double n2 )                               // Accessor method
         
      {
      	 number1 = n1;
      	 number2 = n2;
      }
      
      public double getSum()                                                     // Accessor method
      {
      	 return number1 + number2;
      }

}

My code for TwoNumbersTester.java:

public class TwoNumbersTester
{

    public TwoNumbersTester() 
    {
    }
    
    public void startTest()
    {
       TwoNumbers equation1;
       TwoNumbers equation2;
       
       equation1 = new TwoNumbers( 10 , 15 );                                // Set numbers for equation
       equation2 = new TwoNumbers( 100 , 200 );
       
       //*** Test first instance of TwoNumbers object ***//
          
       System.out.println( equation1.getSum() );                             // Display sum
          
          
       //*** Test second instance of TwoNumbers object ***//
          
       System.out.println( equation2.getSum() );                             // Display sum
    }

    
}

And, my code for Test.java:

public class Test
{

   public static void main ( double args [] )
   {
      TwoNumbersTester test = new TwoNumbersTester();
      
      test.startTest();
   }
    
}

This is about the trillionth error I've attempted to solve in this program, and it's the last one I'm stuck on. Can anyone help me out? Where is my error? Or, is it not in this code and maybe in one of the other objects?

Thanks so much, in advance, for your help!

**I do also just want to add that I'm not looking for a "quick" solution, or a way out of doing my homework. If anyone has help to offer, please explain in a way so that I can understand and learn why whatever I'm doing wrong..is wrong.

Thanks again!!

I'm sorry--I forgot to put the code tags in. I can't seem to go back and edit the post to add them, though. I apologize! Here is my code, reposted in tags:

TwoNumbers.java

public class TwoNumbers extends Object // Class header
{
private double number1; // Instance variables
private double number2;

public TwoNumbers( double n1 , double n2 ) // Constructor method
{
number1 = n1;
number2 = n2;
} 

public void setNums( double n1 , double n2 ) // Accessor method

{
number1 = n1;
number2 = n2;
}

public double getSum() // Accessor method
{
return number1 + number2;
}

}

TwoNumbersTester.java

public class TwoNumbersTester
{

public TwoNumbersTester() 
{
}

public void startTest()
{
TwoNumbers equation1;
TwoNumbers equation2;

equation1 = new TwoNumbers( 10 , 15 ); // Set numbers for equation
equation2 = new TwoNumbers( 100 , 200 );

//*** Test first instance of TwoNumbers object ***//

System.out.println( equation1.getSum() ); // Display sum


//*** Test second instance of TwoNumbers object ***//

System.out.println( equation2.getSum() ); // Display sum
}


}

Test.java

public class Test
{

public static void main ( double args [] )
{
TwoNumbersTester test = new TwoNumbersTester();

test.startTest();
}

}

I really appreciate any help anyone has to offer. I'm having a very difficult time catching on to the OOP concept, and I've been digging through my course book, search engines, forums--you name it--with no luck.

>java.lang.NoSuchMethodError: main Exception in thread "main"

Error description tells you to check signature of main() method.

public class Test
{
   public static void main ([B]String args[][/B] ) {
        TwoNumbersTester test = new TwoNumbersTester();
        test.startTest();
   }
}

Thank you--such a simple solution. I figured it out, and when I came back on here, you confirmed it for me. Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.