Writing a client program to test the stock class help

Hello again, here is the other 15 point question on my test. Hopeing someone can help me fill in the blanks. Thank you in advance. I will be filling in further code as I get it done, if I get it done I should say. If you see typos please point them out.

Regards

In the client program, create a Stock object with stock symbol SUnW, name Sun Mircrosystems Inc, privious closing price of 100. Set a new current price randomly and display the price change percentage.

[code]
public class StockInfo
{
public static void main(String[]args)
{
*******client code belongs here ******

}
}
class Stock
{
private String symbol;
private String name;
private double previousClosingPrice;
private double currentPrice;

public Stock(String symbol, String name)
{
this.symbol=symbol;
this.name=name;
}
public String getSymbol()
{
return symbol;
}
public String getName()
{
return name;
}
public double getPreviousClosingPrice()
{
return previousClosingPrice;
}
public double getCurrentPrice()
{
return currentPrice;
}
public void setSymbol(String symbol)
{
this.symbol=symbol;
}
public void setName(String name)
{
this.name=name;
}
public void setPreviousClosingPrice(double price)
{
this.previousClosingPrice=price;
}
public void setCurrentPrice(double price)
{
this.currentPrice=price;
}
public double changePercent()
{
return(currentPrice-previousClosingPrice)/previousClosingPrice;
}
}
[/code]
PJ
Self torture through education,
but enjoy it!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories