
Hi
if someone could help that would be great
Write a program to read in 10 integer values and output the sum of all the positive integers and the sum of all the negative integers.

import java.util.*;
class Numbers
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int sum1=0,sum2=0;
int num[]=new int[10];
System.out.println("Enter 10 numbers: ");
for(int i=0;i<num.length;i++){
num[i]=input.nextInt();
if(num[i]>0){
sum2+=num[i];
}
else{
sum1+=num[i];
}
}
System.out.println("Sum of positive numbers: "+sum2);
System.out.println("Sum of negative numbers: "+sum1);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.