Coding bat sum67

my solution, looks kinda ugly, but it is unique!

public int sum67(int []nums){
 
    boolean hit6 = false ;
    boolean hit7 = false ;       
    for(int i = 0 ; i < nums.length;i++){
      if( nums[i] == 6 && !hit7){
      
         hit6 = true ;
          nums[i] = 0;
      
      }
     
      else if(nums[i] != 6 && nums[i] !=7 && hit6 && !hit7){
         nums[i] = 0 ;

     
      }
      else if(nums[i] == 6 && hit6 && !hit7){
          nums[i] = 0 ;
       }
      else if( nums[i] == 7 && hit6){
             hit6 = false ;
             hit7 = false ;
                    nums[i] = 0 ;
      }
    }//end of loop
   
   int sum = 0 ;
   for(int i = 0 ; i < nums.length;i++)
        sum += nums[i] ;
    return sum ;
  }

Purpose of the blog



I m a beginner programmer, and i want to improve my coding skills


In this blog i will be posting solutions to various exercises from diff. programming practice websites.



May the force be with me!



codingbat practice

I have solved these exercises in codingbat.com