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 3 of 3

Thread: Help Converting to an Acronym

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Help Converting to an Acronym

    I am trying to convert a list of college majors to their responding acronyms and I am completely stuck. This is what I have so far. Help would be much appreciated.
    import javax.swing.JOptionPane;
    public class Majors {
    public static void main(String args[])
    {
    	String major = JOptionPane.showInputDialog("Type Your Full Major");
    	String majorInitial =" ";
    	if (major == "Technical Resource Management")
    	{
    		majorInitial = "TRM";
    	}
    	JOptionPane.showMessageDialog(null, majorInitial);
    }
    }
    Last edited by helloworld922; February 2nd, 2010 at 04:04 PM. Reason: please use [code] tags!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help Converting to an Acronym

    What exactly are you stuck on? Looks like you are on your way...just add some else if statements for more majors. One minor suggestion would be to use

    major.equals("Technical Resource Management")

    rather than
    major == ""

    A more advance option would be to use a HashMap to store your key/value (eg major/acronym)

  3. The Following User Says Thank You to copeg For This Useful Post:

    CheekySpoon (February 2nd, 2010)

  4. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Help Converting to an Acronym

    Quote Originally Posted by copeg View Post
    What exactly are you stuck on? Looks like you are on your way...just add some else if statements for more majors. One minor suggestion would be to use

    major.equals("Technical Resource Management")

    rather than
    major == ""

    A more advance option would be to use a HashMap to store your key/value (eg major/acronym)
    Thank you so much for the minor suggestion. It works perfectly now!

Similar Threads

  1. How to convert GSM 6.10 wav file to MP3/PCM/OGG/AU format using JAVA?
    By expertise in forum Java ME (Mobile Edition)
    Replies: 4
    Last Post: April 11th, 2014, 02:13 AM
  2. Converting Hex to Decimal
    By r2ro_serolf in forum Java Theory & Questions
    Replies: 10
    Last Post: September 4th, 2011, 04:29 PM
  3. [SOLVED] Java program to convert and compare integers
    By luke in forum What's Wrong With My Code?
    Replies: 9
    Last Post: May 18th, 2009, 06:26 PM
  4. Replies: 4
    Last Post: May 1st, 2009, 03:32 PM
  5. Program to convert Hexadecimal to its Character equivalent
    By nathanernest in forum Java Theory & Questions
    Replies: 2
    Last Post: April 8th, 2009, 03:12 AM