Browse Source

added files

master
Raphael Roberts 7 years ago
parent
commit
c702bcfd4f
  1. 19
      Stock.java
  2. 18
      StockBroker.java

19
Stock.java

@ -0,0 +1,19 @@
public class Stock{
public String name;
public String symbol;
public double openingPrice;
public double closingPrice;
public void getChangeInPrice(){
double change= closingPrice-openingPrice;
System.out.println("Change is" + change);
}
public void printStockInfo(){
System.out.println("Name: " + name);
System.out.println("Symbol: " + symbol);
System.out.println("Opening Price: " + openingPrice);
System.out.println("Closing Price: "+ closingPrice);
}
}

18
StockBroker.java

@ -0,0 +1,18 @@
public class StockBroker{
public static void main(String[]args){
Stock s1 = new Stock();
Stock s2 = new Stock();
s1.name = "Oracle";
s1.symbol = "ORCL";
s1.openingPrice = 205.0;
s1.closingPrice = 203.0;
s2.name = "Microsoft";
s2.symbol = "MCST";
s2.openingPrice = 120.0;
s2.closingPrice = 125.0;
s1.printStockInfo();
System.out.println();
s2.printStockInfo();
}
}
Loading…
Cancel
Save