Howdy, Stranger!

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

Categories

Writing a client program to test the stock class help

PJsPlacePJsPlace Member Posts: 28
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!

Comments

  • Shawn CarterShawn Carter Member Posts: 0

    ____ / http://forcoder.org / free ebooks and video tutorials about // Scratch, Python, Perl, MATLAB, Assembly, Delphi, C#, R, Java, C++, Objective-C, Visual Basic .NET, Go, Ruby, C, Swift, PL/SQL, Visual Basic, PHP, JavaScript Scala, ML, Logo, Clojure, Kotlin, Rust, F#, Hack, SAS, Dart, Julia, Erlang, Alice, LabVIEW, Apex, Bash, Fortran, Lisp, Crystal, COBOL, FoxPro, Scheme, Ada, VBScript, Lua, D, Prolog, ABAP, Transact-SQL, Awk // ____________

Sign In or Register to comment.