Java

I am trying to write an algorithm for my JAVA class and am having some issues....if I were to post my program is there anyone on here that could help me figure out what I am doing wrong? Thanks

  1. 👍 0
  2. 👎 0
  3. 👁 44
asked by Mike
  1. Well perhaps I can help if its around the difficulty of AP Java A(Computer Science A).

    1. 👍 0
    2. 👎 0
  2. 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");

    }

    }
    }

    1. 👍 0
    2. 👎 0
    posted by Mike
  3. 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.

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. pseudo code algorithm

    Convert your algorithm from Question One into a complete Java application. Marks will be allocated based upon: ● Your Java code matching your pseudo code algorithm from Question One. ● Your Java code being syntactically

    asked by husanpreet on April 27, 2016
  2. Programming

    Widget company runs a small factory that makes several types of nuts and bolts. They employ (a)1 (b)2 (c)3. Each factory worker can work a maximum of (a)40 hours normal working hours per week. All hours over 40 are paid as

    asked by Jessica on April 28, 2017
  3. Java Programming

    I'm new to Java and I'm not sure how to write the source code for this problem I got in class... Write a java program using the while and if statement that will accept ten student grades and that will display the sum of the

    asked by Samantha on June 10, 2013
  4. Math

    Write an algorithm to evaluate the average height in class. Get the lengths of the class from the user. Trace your program and show your results.

    asked by Anonymous on September 4, 2016
  5. physics

    n this problem, we will carry out some steps of the quantum factoring algorithm for N=15. (a) What is the period k of the periodic superposition set up by the quantum factoring algorithm if it chooses x=2? (b) Assume that we found

    asked by s on March 22, 2013
  6. Quantum Physics

    In this problem, we will carry out some steps of the quantum factoring algorithm for N = 15 (a) What is the period k of the periodic superposition set up by the quantum factoring algorithm if it chooses x = 2 ? (b) Assume that we

    asked by Gyanno on March 21, 2013
  7. Computer Science

    Consider the following application files: /JavaCS1/src/guiprojectcity2/DisplayWindow.java import java.awt.*; import javax.swing.*; public class DisplayWindow extends JFrame{ private Container c; public DisplayWindow(){

    asked by Sally on July 29, 2011
  8. java

    Write a java application that finds the smallest of several integers. Prompt the user for the number of integers that will be input, then prompt the user for that number of integers. Evaluate the integers to determine the smallest

    asked by saleh on October 21, 2012
  9. Programming

    I need to write a code in java based on an alrgorithm, the alrgorithm and it’s problem are below: The Sieve of Eratosthenes is “a simple, ancient algorithm for finding all prime numbers up to any given limit,” which you can

    asked by Mr. Anonymous on March 10, 2019
  10. Quantum Computing

    In this problem, we will carry out some steps of the quantum factoring algorithm for N=21. (a) What is the period k of the periodic superposition set up by the quantum factoring algorithm if it chooses x=2? In other words, what is

    asked by imath on September 22, 2013

More Similar Questions