Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Return Min

  1. #1
    Member
    Join Date
    Sep 2013
    Posts
    35
    My Mood
    Goofy
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Question Return Min

    I got part of this code written, but I am not sure how to make it so that it will return the smaller of the two passwords entered.

    package password;
     
    /*50. Write a program that reads two words representing passwords from
    //the Java console and outputs the number of characters in the smaller
    //of the two. For example, if the two words are open and sesame, then
    //the output should be 4, the length of the shorter word, open.
     */
    import java.util.Scanner;
     
    public class PassWord
    {
    public static void main( String [] args )
      {
    Scanner scan = new Scanner (System.in );
    System.out.print("Enter your first Password > " );
    String passOne = scan.next( );
    System.out.print("Enter your 2nd Password > " );
    String passTwo = scan.next ( );
    System.out.print("Your password is " + passOne + " Your other password is " + passTwo);
     
      }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Return Min

    Check the String API for methods - well, one method - that may be helpful.

Similar Threads

  1. Replies: 1
    Last Post: July 29th, 2013, 06:22 AM
  2. regarding min-PQ
    By IHeartProgramming in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 15th, 2012, 05:01 PM
  3. Multi-D array. daily max/min/avg, weekly max/min/avg, sum total (99% done)
    By TheWhopper858 in forum Collections and Generics
    Replies: 1
    Last Post: November 6th, 2011, 08:50 PM
  4. Return Object does not return the expected output
    By Nour Damer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 13th, 2011, 07:24 AM
  5. Can't figure out how to use Math.min() or return multiple names
    By Apocalypse in forum Java Theory & Questions
    Replies: 3
    Last Post: October 10th, 2011, 11:25 AM

Tags for this Thread