- 2
A program is to find and display the sum of two numbers only if they are positive integers.
Write this in Java using the following parameters; i. Taking the class name as „exam‟ ii. The output should be in a complete sentence
2 Respostas
+ 1
AJ Anant
Equal and greater than zero would be a better choice since "0" is also a positive number.
0
It's very easy task. Just check if both numbers are greater than 0.
int sum = 0;
if(n1 > 0 && n2 > 0 ) {
sum = n1 + n2;
}