Computer Science, asked by jaybhangade1, 3 months ago

Write a program in java to accept any 10 numbers. Print sum of only the negative numbers.

Answers

Answered by h617155
1

Answer:

import java.util.*;

public class Sum_Negative

{

public static void main(String args[])

{

Scanner in = new Scanner(System.in);

int a=1,n,s=0;

System.out.println("Enter any 10 numbers:");

while(a<=10)

{

n=in.nextInt();

if(n<0)

s=s+n;

a++;

}

System.out.println("The sum of the numbers ="+s):

}

}

Similar questions