Hi everyone;
I have table contains question and answer columns , the answer either yes or no
, I want to count the answer yes and answer no then compare the two results and if the count(answer) yes is greater than count (answer) no print yes
else print no
I have wrote the following code, and I got no results

<%
jmm.Database database = new jmm.Database(pageContext.getServletContext().getRealPath("/WEB-INF/config.txt"));
database.jdbcConnect();
String sqlS , sqlD, sqlNu;
sqlS = "select   count(answer) from useranswers where  answer =’Yes’ ";
sqlD= "select    count(answer) from useranswers  where answer =’No’ ”;

 int yes = Integer.parseInteger(database.jdbcOneRowQuery(sqlS));
 int no= Integer.parseInteger(database.jdbcOneRowQuery(sqlD));


if(yes.get(0)> no.get(0) ){
for(int j=0;j<1;j++){
		out.print("yes");
}
}
else{
out.print("no");
}
database.jdbcConClose();
database = null;
%>

when i replace the code

if(yes.get(0)> no.get(0) ){
for(int j=0;j<1;j++){
		out.print("yes");
}
}
else{
out.print("no");
}

with

for(int j=0;j<1;j++){
		out.print(yes.get(0));
}

i got the number of yes answer , so i though i need to put the if else inside the loop , and it would be

for(int j=0;j<1;j++){
if(yes.get(0)> no.get(0) ){
		out.print("yes");

}
else{
out.print("no");
}
}

but still no result ,

someone help

CoSIS1,
Errors in your code snippet.
1.
No such a method - Integer.parseInteger
Use Integer.parseInt()
2.
Can't assign Integer object reference to int variable.

int yes = Integer.parseInteger(database.jdbcOneRowQuery(sqlS));
 int no= Integer.parseInteger(database.jdbcOneRowQuery(sqlD));

Use following code

int yes=Integer.parseInt(database.jdbcOneRowQuery(sqlID)).intValue();
  ...

3.
yes.get(0) ? yes and no are two int variables.

if(yes> no){
  }
else {
}

thank you adatapost for noticing (Integer.parseInteger())
indeed , i tried the code u provide me but i got the following erroer

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 5 in the jsp file: /t11.jsp
int Generated servlet error:
The method parseInt(String, int) in the type Integer is not applicable for the arguments (Vector)

An error occurred at line: 5 in the jsp file: /t11.jsp
Generated servlet error:
Cannot invoke intValue() on the primitive type int

this when i used

int yes=Integer.parseInt(database.jdbcOneRowQuery(sqlS)).intValue();

but when i used

int yes= Integer.parseInt(database.jdbcOneRowQuery(sqlS));

i got the following error

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 5 in the jsp file: /t11.jsp
Generated servlet error:
The method parseInt(String, int) in the type Integer is not applicable for the arguments (Vector)

________________
thanks for reply

I guess that the return type of database.jdbcOneRowQuery method is Vector class.

String val=database.jdbcOneRowQuery(sqlS).get(0).toString();
int yes= Integer.parseInt(val);

I guess that the return type of database.jdbcOneRowQuery method is Vector class.

String val=database.jdbcOneRowQuery(sqlS).get(0).toString();
int yes= Integer.parseInt(val);

it has been solved :

Vector x,y,z;
x=database.jdbcOneRowQuery(sqlS); 
y=database.jdbcOneRowQuery(sqlD);


String value1=x.toString().replaceAll(("]"), "");
if (value1.startsWith("[")){
  value1 = value1.substring ("[".length());
}

String value2=y.toString().replaceAll(("]"), "");
if (value2.startsWith("[")){
  value2 = value2.substring ("[".length());
}


int satisfied = Integer.parseInt(value1);
int dissatisfied= Integer.parseInt(value2);


if(satisfied > dissatisfied){
out.print("yes");
   
      }
  
      else {
     out.print("No");


   
      }

thank you adatapost
i appreciates your replays

This question has already been answered. Start a new discussion instead.