Alright i need some help, been stuck on a basic task.

I input 2 strings. I need to be able to have it compare the two strings to see which one is shorter, then count how short the item is and out put the number.

ex. Word 1 Hello
word 2 hi
Output: the word with the least letters contains 2 letters.

 * To change this template, choose Tools | Templates
 * and open the template in the editor.

package javaapplication17;

import java.util.*;
 * @author Austin
public class Main {

     * @param args the command line arguments
    public static void main(String[] args) {

                Scanner scan = new Scanner(System.in);
 int PW = 0; int i = 0;
     System.out.print("Enter Word one ");
     String password = scan.nextLine();
     System.out.print("Enter Word two ");
     String password2 = scan.nextLine();


System.out.println(" Shortest number is " +PW+ " letters");

8 Years
Discussion Span
Last Post by BestJewSinceJC

Got it thanks, do i start a new thread for a different issue or can i post it in here?


Post a new thread for a different topic. If the question you asked in here was answered, you should mark the thread as solved with the blue link at the bottom of the thread.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.