I can't seem to get my counting loop to stop if m OR n are <=500. The loop stops only when m hits 499 right now, but I need it to cancel if n is 499. I have tried using a break statement, but I'm not sure what else to do.

Also, I know that it says palindrome....that was an entry error when I started that I haven't fixed because I've been stuck trying to figure this issue out.

public class Palindrom 
{
	private double m2;
	private double n2;
	private double LeftTriple;
	private double InnerTriple;
	private double RightTriple;
	
	public void m2(double m)
	{	
		m2 = m;
	}
	
	public void n2(double n)
	{
		n2 = n;
	}
	
	public void LeftTriple (double m, double n)
	{
			LeftTriple = (n2*n2)-(m2*m2);
	}
	
	public void InnerTriple (double m, double n)
	{
			InnerTriple = 2*m2*n2;
	}
	
	public void RightTriple (double m, double n)
	{
			RightTriple = (n2*n2) + (m2*m2);
	}
	
	public void getTriple()
	{
		System.out.println("[" + LeftTriple + "," + InnerTriple 
				+ "," + RightTriple + "]");
	}
}

And my test of the above class:

import java.util.Scanner;

public class PalindromTest 
{
	public static void main( String[] args ) 
	{
		Palindrom Palindrome1 = new Palindrom();
		
		double n;
		double a; double b;
		double m;
		double i;
		
		Scanner input = new Scanner( System.in );
		
		System.out.println("Please Enter Value for a: ");
		m = input.nextDouble();
		
		System.out.println("Please Enter Value for b: ");
		n = input.nextDouble();
		
		
		if (m<n)
		{
		for (double count = m; m < 499; count++)
		{
			for(i=n; i< 499; i++ );
			{
				Palindrome1.m2(m);
				Palindrome1.n2(n);
				Palindrome1.LeftTriple(m,n);
				Palindrome1.InnerTriple(m,n);
				Palindrome1.RightTriple(m,n);
				Palindrome1.getTriple();
				m++;
				n++;
			}
		}
		}
		else
			System.out.println("ERROR:  Value 1 must be smaller than value 2");
	}
}
if (m<n)
		{
		for (double count = m; m < 499; count++)
		{
			for(i=n; i< 499; i++ );
			{
                           [ SNIP ]
				m++;
				n++;
			}
		}

This is a very confusing way to do a for loop. It'll compile, but it's not at all clear what you mean to do.

The immediate problem is that your loop condition in the inner loop does not check the value of n, it checks i. That means that n's value doesn't affect the loop, it's the value of i that matters.

There's a more serious structural problem, however, and that's that you have your loop condition for the outer loop (m < 499) depending on a value that is only modified in the inner loop. This can easily lead to problems - infinite loops, for example, if you don't enter the inner loop, would be the most obvious.

Also, your declaration of the outer loop is probably wrong in two ways. You don't want to use a double for an index - it should be an int. Double is legal, but not advisable without a good reason. Also, you're declaring a variable "count" which is incremented but not checked, so it's not clear why it's there.

If you'll give a quick synopsis of what you intended, which is not altogether clear, maybe we can re-work your loop so it'll do what you wanted.

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.