import javax.swing.JOptionPane;
public class Summary {
public static void main (String[]args){
String input = JOptionPane.showInputDialog(null,"Enter Number between 0-9999","Summary The Numbers",JOptionPane.QUESTION_MESSAGE);
int Input = Integer.parseInt(input);
if (Input>9999)
{
JOptionPane.showMessageDialog(null,"Please Enter Number between 0-9999");
}
else if (Input>=1000)
{
int x[]= {0,1,2,3};
int i=0 ;
while(i<=3)
{
x[i] = Integer.parseInt(input.substring(i, i+1));
i++;
}
int ans = x[0]+x[1]+x[2]+x[3];
JOptionPane.showMessageDialog(null,"This is summary :: " + ans);
}
else if(Input>=100)
{
int x[]= {0,1,2};
int i=0 ;
while(i<=2)
{
x[i] = Integer.parseInt(input.substring(i, i+1));
i++;
}
int ans = x[0]+x[1]+x[2];
JOptionPane.showMessageDialog(null,"This is summary :: " + ans);
}
else if(Input>=10)
{
int x[]= {0,1};
int i=0 ;
while(i<=1)
{
x[i] = Integer.parseInt(input.substring(i, i+1));
i++;
}
int ans = x[0]+x[1];
JOptionPane.showMessageDialog(null,"This is summary :: " + ans);
}
else if(Input>=0)
{
int x[]= {0};
int i=0 ;
while(i<=0)
{
x[i] = Integer.parseInt(input.substring(i, i+1));
i++;
}
int ans = x[0];
JOptionPane.showMessageDialog(null,"This is summary :: " + ans);
}
else JOptionPane.showMessageDialog(null,"Please Enter Number between 0-9999");
}
}[/b]