InterviewSolution
Saved Bookmarks
| 1. |
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 |
|
Answer» 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 |
|