|
Let me see if I can remember this problem off the
top of my head. It has been a long time. 1. Create Strings to hold the names 2. Get the names. 3. Create new arrays to hold from the split and then split the names which will create an array of Strings. 4. Compare the split first names with each person's first name and print it out. // Step 1 String firstPerson; String secondPerson; // Step 2 firstPerson = JOptionPane.showInputDialog("Please enter your name"); secondPerson = JOptionPane.showInputDialog("Please enter your name"); // Step 3 // creating the two arrays String[] firstPersonName = new String[]; String[] secondPersonName = new String[]; // splitting the two names into the newly created array firstPersonName = firstPerson.split(" "); secondPersonName = secondPerson.split(" "); // Step 4 If (firstPersonName[0].length > secondPersonName[0].length) { System.out.println(firstPersonName[0] + " has longer first name than " + secondPersonName[0]); } else { System.out.println(secondPersonName[0] + " has longer first name than " + firstPersonName[0]) } I hope this works... LOL If it doesn't, it is darn close and you should build off that. Stephen PS. Don't just copy it, understand from it. Look at it and see why it is the way it is. I hope the pseudocode at the top helps you out. Daniel Mays wrote: This is my code: |
- [java programming] need help with lab-1036 Daniel Mays
- Re: [java programming] need help with lab-1036 Retnuh
- [java programming] Re: need help with lab-1036 Ruben
- [java programming] Re: need help with lab-1036 Ruben
