Posted by Mike on Friday, April 4, 2008 at 10:37pm.
Well perhaps I can help if its around the difficulty of AP Java A(Computer Science A).
I will post the program I am trying to run just incase you can help. If you can't no worries. The issue I am having is when I run the program and enter in the number "100, 200, or 300" the box that is supposed to show up should be showing the televion display, description and price" and it does not do that.
import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
public class TVmodel3 {
public static void main(String[] args) {
//Decide model type
String models; //Variable for model
String outputStr; //Variable for output
String salePrice; //Variable for sale price of home
double price;
models = JOptionPane.showInputDialog("Please enter the model number chosen,/nModel 100 comes with remote control, timer,\nand stereo sound and costs $1000, \nModel 200 comes with all features of model 100, \nand picture-in-picture, and costs $1200, \nModel 300 comes with all features of model 200 and /nHDTV, flat screen, 16 x 9 aspect ratio and costs $2400", JOptionPane.INFORMATION_MESSAGE);
int model;
model = 100;
switch (model)
{
case 100:
outputStr = "TV model";
JOptionPane.showMessageDialog(null, outputStr,"You chose model 300 TV with these features:/nHDTV, flat screen, 16 x 9 aspect ratio, /npicture-in-picture, /nremote control, timer and stereo sound /nYour price will be $2400.00",JOptionPane.INFORMATION_MESSAGE);
break;
case 200:
System.out.println ("You chose model 200 TV with these features:");
System.out.println ("remote control, timer,stereo sound");
System.out.println ("and picture-in-picture");
System.out.println ("Your price will be $1200.00");
break;
case 300:
System.out.println ("You chose model 300 TV with these features:");
System.out.println ("HDTV, flat screen, 16 x 9 aspect ratio,");
System.out.println ("picture-in-picture,");
System.out.println ("remote control, timer and stereo sound \nYour price will be $2400.00");
break;
default:
System.out.println("The Model entered is not available or invalid");
}
}
}
My language familiarity is mostly, c, c++, assembler, but here is something to check in your code.
In the code, you are inputing to the string variable "models"; however, the switch statement is on the int "model". The variable "model" is hardcoded to a value of 100 in your code. I am thinking you intended to assign model the value converted from the string variable models.
Related Questions
java - Write a java application that finds the smallest of several integers. ...
Java - Can anybody help me figure how to post a Java file to as an attachment. I...
programming - I am having trouble writing this program for java. can anybody ...
programming.Java language - Write a program to plot a face. Provide a class ...
java - can anyone help me with this? I'm new to java! Write a program that ...
Java help please - I am trying to run the following program and am getting this ...
JAVA PROGRAMMING - "POWERS" Compute the power of a number given the ...
JAVA - simple java program to retrive data from oracle database between specific...
programming - Having troube with java, i am not a regular programmer, if anybody...
Video in java(netbeans) - Hi, i am using netbeans and i'm trying to ...
For Further Reading