In: Computer Science
JAVA
Enter a number> 25
Enter a number> 9
Enter a number> 5
Enter a number> -3
Enter a number> 0
Sum = 39
Here is the required solution
here is the code
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int sum=0;
while(true)
{
System.out.printf("Enter the number>");
int num=sc.nextInt();
if(num==0)
break;
if(num>0)
{
sum=sum+num;
}
}
System.out.println("Sum="+sum);
}
}