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

    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){
    this.name = name;
    this.symbol = symbol;
    this.previousClosingPrice = previousClosingPrice;
    this.currentPrice = currentPrice;
    }
    public String getSymbol(String symbol){
    return this.symbol;
    }
    public String getName(String name){
    return this.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){
    this.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
    Location
    Madgaon, Goa, India
    Posts
    11,303
    Rep Power
    20

    Default Re: The Stock Class and JOptionPane

    Removed from The Stock Class

    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.

    db
    Last edited by DarrylBurke; 04-19-2012 at 05: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-13-2011, 11:45 PM
  2. The Stock Class
    By luckyirish in forum New To Java
    Replies: 9
    Last Post: 07-13-2011, 04:40 AM
  3. Webcrawling www.stock-forecasting.com
    By devasia1000 in forum Networking
    Replies: 0
    Last Post: 02-12-2011, 11:25 AM
  4. Stock exchange program
    By askinne2 in forum New To Java
    Replies: 2
    Last Post: 05-02-2010, 11:25 PM
  5. Stock Quotes
    By BartDR in forum Advanced Java
    Replies: 0
    Last Post: 09-15-2009, 09: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
  •