WAP to accept two numbers and display the sum. Program will exit only if the sum is less than or equals to 0. please answer
Answers
Answered by
1
Answer:
import java. util. Scanner;
public class SumNum
{
public static void main(String[] args)
{
boolean a= true;
while(a==true)
{
Scanner sc= new Scanner(System.in) ;
System.out.print("Enter the first number: ") ;
double num1= sc.nextDouble();
System.out.print("Enter the second number: ") ;
double num2= sc.nextDouble();
double sum=num1+num2;
if(sum<=0)
{
System.exit(0) ;
}
}
}
}
hey as u said, the program exits ONLY WHEN SUM IS LESS THAN OR EQUAL TO zero
Similar questions