Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The "MFCOMSCIEXAMreview" class.
- import java.awt.*;
- import hsa.Console;
- public class MFCOMSCIEXAMreview
- {
- static Console c; // The output console
- public static void main (String[] args)
- {
- c = new Console ();
- String word1 = "";
- String word2 = "";
- String word3 = "";
- int lengthHigh = 0;
- c.println ("Please enter word 1:");
- word1 = c.readLine ();
- c.println ("Please enter word 2:");
- word2 = c.readLine ();
- c.println ("Please enter word 3");
- word3 = c.readLine ();
- lengthHigh = wordLength (word1, word2, word3);
- c.print ("The longest length of all three names is ");
- c.println (lengthHigh);
- }
- public static int wordLength (String word1, String word2, String word3)
- {
- int word1length = 0;
- int word2length = 0;
- int word3length = 0;
- int total = 0;
- int high = 0;
- word1length = word1.length ();
- word2length = word2.length ();
- word3length = word3.length ();
- String[] word = {word1, word2, word3};
- for (int i = 0 ; i < word.length ; i++)
- {
- if (word [i] > high)
- {
- high = word [i];
- }
- }
- return high;
- }
- // Place your program here. 'c' is the output console
- // main method
- } // MethodApp2 class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement