I have created an apex class as per your requirement.
public class EvenAndOdd {
public static void findOddAndEvenNumber(Integer x){
Integer y = x/2;
System.debug('Number'+y);
Integer z = y * 2;
if(x == z ){
System.debug('The number is even.');
}else{
System.debug('The number is odd.');
}
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards, Ajay Dubedi www.ajaydubedi.com
Please see the given below code and link with the help of this, you can solve your problem, it may be helpful to you.
public class EvenAndOddApex {
public static void findOddAndEvenNumber(Integer num){
Integer num1 = num/2;
System.debug('Number>>>>'+num1);
Integer result = num1 * 2;
if(num == result ){
System.debug("The given number is even.");
}else{
System.debug("The given number is odd.");
}
}
}
For another example you can follow the below link as well: Link: https://webkul.com/blog/apex-programming-basics/
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards, Deepali Kulshrestha www.kdeepali.com
Hope this link give solution. I havn't tried yet.
http://salesforcehelps.blogspot.com/2016/09/odd-even-number-in-salesforce.html
Thanks
You can use the below code:
I have created an apex class as per your requirement.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Please see the given below code and link with the help of this, you can solve your problem, it may be helpful to you.
For another example you can follow the below link as well:
Link: https://webkul.com/blog/apex-programming-basics/
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com