Display data in form of triangle in reverse
import javax.swing.JOptionPane;
public class display_data_tri2
{
public static void main(String[] args)
{
String sRes="";
String sData=JOptionPane.showInputDialog("enter data");
for (int i=sData.length() ;i>=1;i--)
{
sRes=sRes+sData.substring(0, i)+"\n";
}
System.out.print(sRes);
}
}
No comments:
Post a Comment