Updated Java Program 3, Added Java Program 4