SHARE
TWEET

Untitled

a guest Feb 17th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /**
  3.  * Write a description of class Stock here.
  4.  *
  5.  * @author Quinn Souza
  6.  * @version 2/17/19
  7.  */
  8. public class Stock
  9. {
  10.     // instance variables - replace the example below with your own
  11.     private string symbol;
  12.     private double price;
  13.     private double bypercent
  14.     /**
  15.      * Constructor for objects of class Stock
  16.      */
  17.    
  18.    
  19.     public Stock(String sym, double currentprice)
  20.     {
  21.         // initialise instance variables
  22.         symbol = sym;
  23.         price = currentprice;
  24.     }
  25.  
  26.     /**
  27.      * An example of a method - replace this comment with your own
  28.      *
  29.      * @param  y  a sample parameter for a method
  30.      * @return    the sum of x and y
  31.      */
  32.     public String getSymbol()
  33.     {
  34.         return symbol;  
  35.     }
  36.     public double getPrice()
  37.     {
  38.         return price;
  39.     }
  40.     public void changePrice(double byPercent)
  41.     {
  42.         if bypercent < 0
  43.         {
  44.            double percent1 = (bypercent/100) * currentprice;
  45.            currentprice = doubleprice - percent1;
  46.         }
  47.         else
  48.         {
  49.            double percent2 = (bypercent/100) * currentprice;
  50.            currentprice = doubleprice + percent2;
  51.            
  52.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top