/* * This program will do a bit of character string processing */ package stringthing; import npw.OrangeDots; import painter.SPainter; import shapes.SSquare; import javax.swing.*; import java.awt.*; public class StringThing { public static void main(String[] args){ //POINT A: CREATE A PRINT SOME STRING THAT REPRESENT NAME String singer = "Holiday, Billie"; String sculptor = "Claudel, Camille"; String painter = "Picasso, Pablo"; String dancer = "Zotto, Osvaldo"; String self = "Enaboifo, Odion"; System.out.println("\nNames ... " + singer + " | " + sculptor + " | " + painter + " | " + dancer + " | " + self); //POINT B: COMPUTE AND PRINT THE LENGTH OG THE STRINGS, WITHOUT LABELS int singerLength = singer.length(); int sculptorLength = sculptor.length(); int painterLength = painter.length(); int dancerLength = dancer.length(); int selfLength = self.length(); System.out.println("\nNames lengths... " + singerLength + " | " + sculptorLength + " | " + painterLength + " | " + dancerLength + " | " + selfLength); //POINT C: COMPUTE AND PRINT THE LOCATION OF THE COMMA WITHIN EACH STRING, NO LABELS String singerCommaPosition = singer.substring(7,8); String sculptorCommaPosition = sculptor.substring(7,8); String painterCommaPosition = painter.substring(7,8); String dancerCommaPosition = dancer.substring(5,6); String selfCommaPosition = self.substring(8,9); System.out.println("\nComma... " + singerCommaPosition + " | " + sculptorCommaPosition + " | " + painterCommaPosition + " | " + dancerCommaPosition + " | " + selfCommaPosition); //POINT D: COMPUTE AND PRINT THE FIVE FIRST NAMES, WITH NO LABELS String singerFirst = singer.substring(9); String sculptorFirst = sculptor.substring(9); String painterFirst = painter.substring(9); String dancerFirst = dancer.substring(7); String selfFirst = self.substring(10); System.out.println("\nFirst names... " + singerFirst + " | " + sculptorFirst + " | " + painterFirst + " | " + dancerFirst + " | " + selfFirst); //POINT E: COMPUTE AND PRINT THE FIVE LAST NAME, WITH NO LABELS String singerLast = singer.substring(0,7); String sculptorLast = sculptor.substring(0,7); String painterLast = painter.substring(0,7); String dancerLast = dancer.substring(0,5); String selfLast = self.substring(0,8); System.out.println("\nFirst names... " + singerLast + " | " + sculptorLast + " | " + painterLast + " | " + dancerLast + " | " + selfLast); //POINT F: COMPUTE AND PRINT THE FIRST NAMES, AGAIN System.out.println("\nFirst names, once again..."); System.out.println(firstName(singerFirst)); System.out.println(firstName(sculptorFirst)); System.out.println(firstName(painterFirst)); System.out.println(firstName(dancerFirst)); System.out.println(firstName(selfFirst)); //POINT G: COMPUTE AND PRINT THE LAST NAME, AGAIN System.out.println("\nLast names, once again..."); System.out.println(lastName(singerLast)); System.out.println(lastName(sculptorLast)); System.out.println(lastName(painterLast)); System.out.println(lastName(dancerLast)); System.out.println(lastName(selfLast)); //POINT H: COMPUTE AND PRINT THE FULL NAMES, NATURAL STYLE System.out.println("\nFull names, natural style..."); System.out.println(fullName(firstName(singerFirst) + " " + lastName(singerLast))); System.out.println(fullName(firstName(sculptorFirst) + " " + lastName(sculptorLast))); System.out.println(fullName(firstName(painterFirst) + " " + lastName(painterLast))); System.out.println(fullName(firstName(dancerFirst) + " " + lastName(dancerLast))); System.out.println(fullName(firstName(selfFirst) + " " + lastName(selfLast))); } private static String firstName(String directoryStyleName) { return directoryStyleName; } private static String lastName(String directoryStyleName) { return directoryStyleName; } private static String fullName(String dsn) { return dsn; } }