Computer Science, asked by xxxse, 11 months ago

Write a program in java to display the sum of any two numbers for ten iterations. If the sum of two numbers is negative then the program terminates.

Answers

Answered by Anonymous
21

import java.util.*;

public class Dispaly

{

public static void main(String args[])

{

Scanner in = new Scanner(System.in);

int a,b,c,i;

for(i=1;i<=10;i++)

{

System.out.println("Enter two numbers");

a=in.nextint();

b=in.nextInt();

c=a+b;

if(c<0)

break;

System.out.println("Sum of the two numbers:" +c);

}

System.out.println("Program terminates");

}

}

Similar questions