Uploaded by Prashant Pandey

q9

advertisement
import java.util.Scanner;
class q9{
public static void main(String args[]){
/* Byte b1 = new Byte(125);
Byte b2 = Byte.valueOf(b1);
System.out.println(b2);*/
System.out.println("Enter the no. between 10 and 1000 :");
Scanner sc =new Scanner(System.in);
int n = sc.nextInt();
if ((n>=10)&&(n<=99)){
int a= n%10;
int b= n/10;
System.out.println("Sum of digits : "+(a+b));
}
else if ((n>=100)&&(n<=999)) { int a= n/100;
int b= n%100;
int c= b%10;
int d= b/10;
System.out.println("Sum of digits : "+(a+c+d)); }
else if (n==1000){ System.out.println("Sum of digits : 1"); }
else {
System.out.println("Please Enter the integer no. in Range i.e 100<= and <=1000");
} }
}
Download