View Single Post
  #21 (permalink)  
Old 04-23-2008, 04:25 PM
raj reddy raj reddy is offline
Member
 
Join Date: Apr 2008
Posts: 30
raj reddy can only hope to improve
hi Sanjeev


The code is exactly working fine.

BUT I NEED TO GET THE PRIZE LEVELS DEPENDING UPON THE NUMBER OF COUNTS;


I HAVE GIVEN THE count++ in the for loop.


but am not getting the updated count value ;



can u please check and resubmit the code whether the count++ i have given in the loop is at correct location or not.





import java.util.ArrayList;
public class CompareList
{

public static void main(String[] args){
ArrayList list1 = new ArrayList();
list1.add(10);
list1.add(20);
list1.add(30);
list1.add(40);
ArrayList list2 = new ArrayList();
list2.add(11);
list2.add(12);
list2.add(13);
list2.add(14);
list2.add(15);
list2.add(16);
list2.add(17);
list2.add(18);
list2.add(19);
list2.add(20);

int s = 1;

int count=1;

for (int i=0;i<list2.size();i++) {
if(s <= 4){
System.out.println("here..:"+list2.get(i));
for (int j=0;j<list1.size(); j++) {
if(list2.get(i).equals(list1.get(j)))

count++;

System.out.println("equals..:"+list1.get(j));
}
s++;
}else{
System.out.println("Checked Four elements, Now checking next Four");
s = 1;
i--;
}
}


if(count==al2.size()-4) {
System.out.println("The level of the prize is FOUR "+count);
}else if(count==al2.size()-3) {
System.out.println("The level of the prize is THREE"+count);
} else if(count==al2.size()-2) {
System.out.println("The level of the prize is TWO "+count);
} else if(count==al2.size()-1) {
System.out.println("The level of the prize is ONE "+count);
} else if(count==al2.size()-0) {
System.out.println("The level of the prize is ZERO "+count);
}
else System.out.println("There is no prize level ");

}
}

Last edited by raj reddy : 04-23-2008 at 04:28 PM.
Reply With Quote
Sponsored Links