Exercise
Function write centered
Objetive
Write a java function to write centered on screen the text that is indicated as a parameter (supposing a screen width of 80 characters):
WriteCentered("Hello!");
Example Code
public class WriteCentered
{
public static void WriteCentered(string text)
{
int i = 0;
for (; i < 17; i++)
{
System.out.println();
}
for (i = 0; i < 36; i++)
{
System.out.print(" ");
}
System.out.print(text);
for (i = 0; i < 14; i++)
{
System.out.println();
}
}
public static void main(String[] args)
{
WriteCentered("Hello");
}
}