Results 1 to 2 of 2
  1. #1
    sofamous426 is offline Member
    Join Date
    Apr 2012
    Rep Power

    Default The Stock Class and JOptionPane

    import javax.swing.JOptionPane;

    public class Stock {
    String symbol;
    String name;
    double currentPrice;
    double previousClosingPrice;

    public static void main(String[] args) {
    Stock stock = new Stock ("ABC","Name.",60,65);
    JOptionPane.showMessageDialog(null,"Symbol: " + stock.getSymbol(null)
    + "\n Name: " + stock.getName(null)
    + "\n Previous Closing Price: " + stock.getPreviousClosingPrice(null)
    + "\n Current Price: " + stock.getcurrentPrice(null)
    + "\n Percentage change in price: " + stock.changePercent());

    public Stock(){

    public Stock (String symbol, String name, double currentPrice, double previousClosingPrice){ = name;
    this.symbol = symbol;
    this.previousClosingPrice = previousClosingPrice;
    this.currentPrice = currentPrice;
    public String getSymbol(String symbol){
    return this.symbol;
    public String getName(String name){
    public double getPreviousClosingPrice(String previousClosingPrice){
    return this.previousClosingPrice;
    public double getcurrentPrice(String currentPrice){
    return this.currentPrice;
    public void setSymbol(String symbol){
    this.symbol = symbol;
    public void setName(String name){ = name;
    public void setPreviousClosingPrice(double previousClosingPrice){
    this.previousClosingPrice = previousClosingPrice;
    public void setcurrentPrice(double currentPrice){
    this.currentPrice = 60.0;
    public double changePercent(){
    return((previousClosingPrice - currentPrice) / previousClosingPrice)*100;


    //"This code provides a dialog box using the JOptionPane"
    //Jarris Alex

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: The Stock Class and JOptionPane

    Removed from

    When you have a question, start a new thread. Don't hijack another poster's thread and don't post to threads that are long dead. Do you have a question, or were you adding your code to a thread where the question had already been resolved?

    The first response in the thread you posted this in mentioned formatting code correctly. Clearly, you ignored it. If you're going to respond to threads here, make sure to read the entire thread before posting.

    Last edited by DarrylBurke; 04-19-2012 at 06:12 AM.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Stock Feeds Code
    By javaderivatives in forum New To Java
    Replies: 1
    Last Post: 12-14-2011, 12:45 AM
  2. The Stock Class
    By luckyirish in forum New To Java
    Replies: 9
    Last Post: 07-13-2011, 05:40 AM
  3. Webcrawling
    By devasia1000 in forum Networking
    Replies: 0
    Last Post: 02-12-2011, 12:25 PM
  4. Stock exchange program
    By askinne2 in forum New To Java
    Replies: 2
    Last Post: 05-03-2010, 12:25 AM
  5. Stock Quotes
    By BartDR in forum Advanced Java
    Replies: 0
    Last Post: 09-15-2009, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts