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.
Code :
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);
}
}
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
Code :
major.equals("Technical Resource Management")
rather than
A more advance option would be to use a HashMap to store your key/value (eg major/acronym)
Re: Help Converting to an Acronym
Quote:
Originally Posted by
copeg
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
Code :
major.equals("Technical Resource Management")
rather than
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!