Hunter2012
Member
- Joined
- Oct 18, 2009
- Messages
- 44
- Reaction score
- 0
- Points
- 6
I'm a beginner at Java Programming and I'm having problems with a part of my program. Heres a piece of the code towards the end.
String Option4 = JOptionPane.showInputDialog("For Designer Furniture with Cloth Upholstery Enter 1 \n" +
"For all Above Plus Captains Chair with Leather Upholstery enter 2 \n" +
"For all Above Plus Plush Carpet Cermaic Tiling, and Wood Panels Enter 3 \n" +
"For all Above Plus Gold Kitchen & Bath Fixtures, Jacuzz and Sauna Enter 4 \n");
if(Integer.parseInt(Option4)== 1)
{
double opt4 = 15000;
}
else if(Integer.parseInt(Option4) == 2)
{
double opt4 = 20000;
}
else if(Integer.parseInt(Option4) == 3)
{
double opt4 = 30000;
}
else if(Integer.parseInt(Option4) == 4)
{
double opt4 = 35000;
}
else
{
String errorMessage = "Incorrect Input for Motor Home.";
JOptionPane.showMessageDialog(null,errorMessage);
}
/** This it the calculations part of the program
*
*/
double totalHomeCost = Opt1 + Opt2 + Opt3 + opt4;
for some reason it keeps coming up with an error message saying that it cant find the symbol/variables for Opt1 Opt2 etc. All of my variables have been declared in the same manner as above with the If statements, so why wont it let me add them together?
String Option4 = JOptionPane.showInputDialog("For Designer Furniture with Cloth Upholstery Enter 1 \n" +
"For all Above Plus Captains Chair with Leather Upholstery enter 2 \n" +
"For all Above Plus Plush Carpet Cermaic Tiling, and Wood Panels Enter 3 \n" +
"For all Above Plus Gold Kitchen & Bath Fixtures, Jacuzz and Sauna Enter 4 \n");
if(Integer.parseInt(Option4)== 1)
{
double opt4 = 15000;
}
else if(Integer.parseInt(Option4) == 2)
{
double opt4 = 20000;
}
else if(Integer.parseInt(Option4) == 3)
{
double opt4 = 30000;
}
else if(Integer.parseInt(Option4) == 4)
{
double opt4 = 35000;
}
else
{
String errorMessage = "Incorrect Input for Motor Home.";
JOptionPane.showMessageDialog(null,errorMessage);
}
/** This it the calculations part of the program
*
*/
double totalHomeCost = Opt1 + Opt2 + Opt3 + opt4;
for some reason it keeps coming up with an error message saying that it cant find the symbol/variables for Opt1 Opt2 etc. All of my variables have been declared in the same manner as above with the If statements, so why wont it let me add them together?