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