Write a java program to calculate sum of three numbers using while loop and skip the statement in the loop using continue statement when the number entered by the user is 2 digit or more tan that.
Sam420:
its a c++ program sry
Answers
Answered by
2
import java.util.*;
class Sum
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n=3,a,s=0;
while(n>=0)
{
System.out.println("Enter a number");
a=sc.nextInt();
if(a>=10)
continue;
s=s+a;
}
System.out.println("The sum is "+s);
}
}
class Sum
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int n=3,a,s=0;
while(n>=0)
{
System.out.println("Enter a number");
a=sc.nextInt();
if(a>=10)
continue;
s=s+a;
}
System.out.println("The sum is "+s);
}
}
Similar questions