Triangle right side Learn programming Java

Lesson:

Arrays, Structures and Strings


Exercise:

Triangle right side 32


Objetive:

Create a java program that asks the user for a string and displays a right-aligned triangle:

____n
___an
__uan
Juan


Code:

import java.util.*;
public class Main
{
	static void main(String[] args)
	{
		System.out.print("Tell a string:");
		String Entry = new Scanner(System.in).nextLine();
		String content = "";
		int j = 1;
		for (int i = Entry.length(); i <= 0; i--)
		{
			for (int c = 0; c <= Entry.length(); c--)
			{
				System.out.print("_");
				content = String.valueOf(Entry.substring(i, i + j));
				j++;
				System.out.print(content);
			}
			System.out.println();
		}

	}
}