1 Replies - 234 Views - Last Post: 16 October 2011 - 10:31 AM Rate Topic: -----

#1 hsaunds  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 16-October 11

Program compiling but not returning anything

Posted 16 October 2011 - 10:02 AM

My code is compiling but not returning true or false! It's testing whether an array is valid using 3 methods. For it to be valid, the array must be 16 digits between 0 and 9. If you double every even indexed element and add up the new array, it must be divisible by 10. I'm really stuck and it's driving me crazy. Any guidance that helps me solve these issues is greatly appreciated!

public class OnlineStore
{
	int[] cardArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 0 };

	public static void main(String[] args) 
	{	
	}
		
		   int findLength = cardArray.length;
	    							
            boolean getRange(){
            	
			for (int i = 0; i < findLength; i++)
				if(0 > cardArray[i] || cardArray[i] >9) {
				  return false; }
            	return true;	
			  }
            
       
            int getSum(){
            
	        for (int j=0; j < findLength; j= j+2)
			 cardArray[j] = cardArray[j]*2;	
	                    
	        int sum = 0;
	        for(int j = 0; j < findLength; j++){
	        sum = sum + cardArray[j];
	        }
	        return sum%10;
	        }
               
            
boolean validateNumber(){
if ((findLength != 16) || (getRange() == false) || (getSum() != 0)){
			return false; }
return true;
}
}




Is This A Good Question/Topic? 0
  • +

Replies To: Program compiling but not returning anything

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2089
  • View blog
  • Posts: 3,181
  • Joined: 21-June 11

Re: Program compiling but not returning anything

Posted 16 October 2011 - 10:31 AM

You're never actually calling your validateNumber method. Your main method is empty.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1