public class FirstHalf {

    public static void main (String [] args) throws IOException {
	// Setting up the reading:
	// Create a buffered reader
	BufferedReader in = new BufferedReader(
			new InputStreamReader(;
	// to read a line of input, use in.readLine();

	// prompt the user:
	String input = in.readLine();

	// find out the length of the string
	int i = input.length();

	// break it into two halves:
	String first = input.substring(0, i/2);
	String second = input.substring(i/2, i);

	// convert the first half to upper case:
	first = first.toUpperCase();

	// convert the second half to lower case: 
	second = second.toLowerCase();

	// construct the resulting string, print it out:
	String result = first + second;



This is an example from CSci 1211 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.