Stock - { this.stockName = name; } public void...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/**Trinity Martin *IT 218 *Week 04 *Lab *This program gives information about a stock */ * package cruft; import javax.swing.JOptionPane; public class Stock{ String stockSymbol; String stockName; double previousClosingPrice; double currentPrice; d public Stock() { this("defaultSym", "defaultName" ); setCurrentPrice(0); setPreviousClosingPrice(0); } public Stock(String symbol, String name) { setSymbol(symbol); setName(name); setCurrentPrice(65); setPreviousClosingPrice(60); } public String getSymbol() { return stockSymbol; } public String getName() { return stockName; } public double getPreviousClosingPrice() { return previousClosingPrice; } public double getCurrentPrice() { return currentPrice; } public void setSymbol(String symbol) { this.stockSymbol = symbol; } public void setName(String name)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { this.stockName = name; } public void setPreviousClosingPrice(double price) { this.previousClosingPrice = price; } public void setCurrentPrice(double price) { this.currentPrice = price; } public double changePercent() { double percent = this.currentPrice - this.previousClosingPrice / this.currentPrice; return percent; } public static void main(String args) { Stock stock = new Stock("ESI", "ITT Technical Institute Inc."); S String output = "Symbol: " + stock.stockSymbol + "\n Name: " + stock.stockName + "\n Previous Closing Price: " + stock.previousClosingPrice + "\n Current Price: " + stock.currentPrice + "\n Price Change: " + stock.changePercent(); JOptionPane.showMessageDialog(null, output); } }...
View Full Document

Page1 / 2

Stock - { this.stockName = name; } public void...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online