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; } }
Program compiling but not returning anything
Page 1 of 11 Replies - 496 Views - Last Post: 16 October 2011 - 10:31 AM
#1
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!
Replies To: Program compiling but not returning anything
#2
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.
Page 1 of 1