[SOLVED] Using dialog boxes and switch statements question
I'm a newb to Java and doing my best to learn on my own, without much help but the book I have is tough to figure out. If anyone could help me out I would surely appreciate it. I am doing a Lab exercise where I am expected to write a program to display a dialog box to the user asking what their choice of three models of televisions will be. They are to enter the model number: 100, 200, or 300. I am to write a switch structure that will, based on their selection, display in a dialog box their choice along with the feature set and price of the model they chose. I have started my code but I checked after the first case to see how it would compile and I am getting the following message:
Quote:
Tvs.java:31: cannot find symbol
symbol : variable output
location: class Tvs
output.Str = "You chose model " + model + "TV with these features:" + "\n"
I am not sure why I am getting this message unless I am not declaring a variable that I'm supposed to, but I really don't know how I should declare one for the output string.
Here is my code:
Code:
import java.util.*;
import java.io.*;
import javax.swing.JOptionPane;
public class Tvs
{
public static void main(String[] args)
{
String inputStr;
String outputStr;
int model;
inputStr = JOptionPane.showInputDialog
("This program asks the user to enter a television model number." +"\n"
+ "The description of the model chosen will be displayed" + "\n"
+ "\n"
+ "\n"
+ "Please enter the model chosen" + "\n"
+ "Model 100 comes with remote control, timer," + "\n"
+ "and stereo sound and costs $1000" + "\n"
+ "Model 200 come with all features of model 100" + "\n"
+ "and picture-in-picture, and costs $1200" + "\n"
+ "Model 300 comes with all features of model 200 and" + "\n"
+ "HDTV, flat screen, 16x9 aspect ratio and costs $2400" + "\n");
switch (model)
{
case 100:
output.Str = "You chose model " + model + "TV with these features:" + "\n"
+ "Remote control, timer, and stereo sound" + "\n"
+ "Your price will be $1000.00" + "\n";
JOptionPane.showMessageDialog(null, outputStr,
"Television Selection",
JOptionPane.INFORMATION_MESSAGE);
case 200:
}
}
}