Go Back   Java Programming Forums > Java Standard Edition Programming Help > What's Wrong With My Code?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2010, 03:35 PM
Junior Member
 

Join Date: Feb 2010
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
CheekySpoon is on a distinguished road

I'm feeling Confused
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.
Java 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);
}
}




Last edited by helloworld922; 02-02-2010 at 08:04 PM. Reason: please use [code] tags!
Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 02-02-2010, 04:46 PM
copeg's Avatar
Moderator
 
6 Highscores

Join Date: Oct 2009
Posts: 677
Thanks: 8
Thanked 149 Times in 141 Posts
copeg will become famous soon enoughcopeg will become famous soon enough
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

Java Code
major.equals("Technical Resource Management")
rather than
Java Code
major == ""
A more advance option would be to use a HashMap to store your key/value (eg major/acronym)
Reply With Quote
The Following User Says Thank You to copeg For This Useful Post:
CheekySpoon (02-02-2010)
  #3 (permalink)  
Old 02-02-2010, 05:37 PM
Junior Member
 

Join Date: Feb 2010
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
CheekySpoon is on a distinguished road

I'm feeling Confused
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

Java Code
major.equals("Technical Resource Management")
rather than
Java Code
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!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Hex to Decimal r2ro_serolf Java Theory & Questions 8 10-11-2009 06:07 PM
[SOLVED] Converting to and comparing integers. luke What's Wrong With My Code? 9 18-05-2009 11:26 PM
Converting GSM 6.10 Wav file to other formats expertise Mobile Applications 3 11-05-2009 11:24 AM
converting to .exe haygaurav Java IDEs 4 01-05-2009 08:32 PM
Converting Hexadecimal to Char nathanernest Java Theory & Questions 2 08-04-2009 08:12 AM


100 most searched terms
Search Cloud
2d arraylist java actionlistener actionlistener in java actionlistener java addactionlistener addactionlistener in java addactionlistener java applications of oops could not create java virtual machine xp double format java double to int java double to integer in java double to integer java eclipse shortcut keys eclipse tutorial for beginners exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double java get mouse position java http://www.javaprogrammingforums.com/object-oriented-programming/3713-limiting-decimal-places-double.html java 2d arraylist java actionlistener java addactionlistener java double format java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programmers forum java programming forum java programming forums java programming help java project ideas java sendkeys java two dimensional arraylist java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton actionlistener jtextarea font jtextarea font color jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream two dimensional arraylist java writing ipod apps

All times are GMT. The time now is 11:59 PM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.