public class Solution {

public boolean isHappy(int n) {

if(n==1){

return true;

}

if(n<=0){

return false;

}

```
Stack sta = new Stack<Integer>();
int sum=0;
do{
if(sum==0)
{}
else {
{n=sum;
sum=0;
}
}
while(n>=10){
int x = n%10;
sum += (x*x);
n/=10;
}
sum+=Math.pow(n,2);
}while(sum >= 10);
if(sum ==1)
{return true;}
else
return false;
}
```

}