Respuesta :
Answer:
//declare variable and initialize to 0
int odd=0;
//declare variable and initialize to 0
int oddCount=0;
//declare variable and initialize to 0
int evenCount=0;
//declare variables and initialize to 0 and 1
int even=0, i=1;
//iterates when i is greater than 0
while (i>0)
{
// get input in the variable i from the user
i = stdin.nextInt();
//check that i divided by 0, its remainder is 0 and i is greater than 0
if ((i % 2)==0 && (i>0))
{
//then, add the variable even with i
even+=i;
//and increase the count of the even by 1
evenCount++;
}
//check that i divided by 0, its remainder is not 0 and i is greater than 0
if ((i % 2)!=0 && (i>0))
{
//then, add the variable odd with i
odd+=i;
//and increase the count of the odd by 1
oddCount++;
}
}
//then, print the following message
System.out.print(even + " " + odd + " " + evenCount + " " + oddCount);
Explanation:
The following are the description of the program.
- Firstly, declare the integer type variables 'odd', 'evenCount', 'oddCount', 'even' and initialize them to 0.
- Then, set the while loop statement that iterates when the variable 'i' is greater than 0. Then, set the if conditional statement to check that the variable 'i' divided by 0, its remainder is 0 and the variable 'i' is greater than 0, then add the variable 'even' with 'i' and increase the count of the even by 1.
- Again check that the variable 'i' divided by 0, its remainder is not 0 and the variable 'i' is greater than 0 then, add the variable 'odd' with the variable 'i' and increase the count of the odd by 1.
- Finally, print the following message with the output.