Greetings!
I'm taking a Java course and I'm working on a *simple* program and have run into a rut that I hope you can help me resolve! This program basically asks you what month you were born and then, for the purposes of a future calculation, it converts the month you type into an integer value for that month (e.g. December->12). But this step is what I cannot perform. Here is the portion of the code in question, any suggestions?
String birthMonth=JOpt ionPane.showInp utDialog("what month were you born?");
if (birthMonth.equ als("January"))
{
birthMonth = new Integer("1");
}
as you can see, I'm clearly trying to tell the computer that if the user enters january, then redefine that variable string they entered into a new integer numbered 1. BlueJ does not like this, because I've already defined birthmonth. So any suggestions?
I'm taking a Java course and I'm working on a *simple* program and have run into a rut that I hope you can help me resolve! This program basically asks you what month you were born and then, for the purposes of a future calculation, it converts the month you type into an integer value for that month (e.g. December->12). But this step is what I cannot perform. Here is the portion of the code in question, any suggestions?
String birthMonth=JOpt ionPane.showInp utDialog("what month were you born?");
if (birthMonth.equ als("January"))
{
birthMonth = new Integer("1");
}
as you can see, I'm clearly trying to tell the computer that if the user enters january, then redefine that variable string they entered into a new integer numbered 1. BlueJ does not like this, because I've already defined birthmonth. So any suggestions?
Comment