Exercise:
1.Write a program TenHelloWorlds.java that prints "Hello, World" ten times.
2.Modify UseArgument.java to make a program UseThree.java that takes three names and prints out a proper sentence with the names in the reverse of the order given, so that for example, "java UseThree Alice Bob Carol" gives "Hi Carol, Bob, and Alice.".
3.Write a program Initials.java that prints your initials using nine rows of asterisks like the one below.
** *** ********** ** * ** ** *** ** ** ** *** ** ** *** ** ** ** ** ** ** ** *** ** ** ** ** ** ** ***** ** ** ** ** ** ** ** *** ** ** ** ** ** ** ** *** ** ** ** ** ** ** ** *** ** ** *** *** ** *** ********** * *
Code:
1.
public class TenHelloWorld {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
System.out.println("Hello, World!");
}
}
public class UseThree {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print("Hi ");
System.out.print(args[0]+", ");
System.out.print(args[1]+", ");
System.out.println(args[2]+", ");
}
}
3.
public class Initials {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(" **** ** ************ ");
System.out.println(" ** ** ** **");
System.out.println("** ** ** **");
System.out.println(" ** ** **");
System.out.println(" **** ** **");
System.out.println(" ** ** **");
System.out.println("** ** ** ** **");
System.out.println(" ** ** ** ** **");
System.out.println(" **** ************ ****");
}
}