29. JAVA Program To Check Status of a given Problem using Nested If Condition.
How does this program work?
- In this program you are going to learn about How to check status using nested if condition in Java.
Here is the code
public class Sum
{
public static void main(String arg[] )
{
int n,sum=0;
System.out.println("Enter how many numbers do you want:\n");
Scanner obj=new Scanner(System.in );
n=obj.nextInt();
int a[]=new int[n];
System.out.println("Enter the "+n+" numbers ");
for ( int i=0;i < n;i++ )
{
System.out.println("Enter number "+(i+1)+":");
a[i]=obj.nextInt();
}
for( int i=0;i < n;i++)
{
sum+=a[i];
}
System.out.println("sum of "+n+" numbers is ="+sum);
}
}