title: Turning an int into a fraction, help please
body: <p>I have an assignment due for a programming class that requires me to put all my variables as int's but needs me to put one of the values as a fraction but the result gives me 0 for the fraction and I dont know how to make it work without changing the value to a double which i cant do. How do i turn an int into a fraction? `</p>
  
  <pre><code>private String companyname;
  private int stockamount;
  private int currentprice;
  private int eightsprice;
  
  
  
  public StockPortfolio (String compName, int sAmount, int nPrice, int ePrice) 
  { 
    companyname = compName;
    stockamount = sAmount;
    currentprice = nPrice;
    eightsprice = ePrice;       
    this.newcprice = newcprice;
    this.new8price = new8price;
  }
  
  public String getName()
  {
     return companyname;
  }
  
     public int getStock()
  {
     return stockamount;
  }    
  
     public int getPricenorm()
  {
     return currentprice;
  }
  
     public int getPrice8th()
  {
     return eightsprice;
   } 
  
     public int getNewPrice()
  {
     return newcprice;
  }
  
     public int getNew8Price()
  {
     return new8price;
  }
  
     private int newcprice;
     private int new8price;   
  
  public void changePrice(int newcprice, int new8price)
  {   
      currentprice = currentprice + newcprice;
      eightsprice = eightsprice + new8price;
  }
  
  
  public int getValue()
  
  {
     return (getStock()*(getPricenorm()+getPrice8th())); 
  }
  
      }
  </code></pre>
  
  <p>`
  This is the test class which i still havent finished because i just want to solve the fraction part out first.</p>
  
  <pre><code>public class StockPortfolioTest {
  
  public static void main(String[] args) {
  StockPortfolio portfolio = new StockPortfolio("The Ramjac Corporation", 100, 37, 5/8);
  System.out.println("Company: " + portfolio.getName());
  System.out.println("Shares Held: " + portfolio.getStock());
  System.out.println("Opening price per sale: " + portfolio.getPricenorm() + " " + portfolio.getPrice8th());
  portfolio.changePrice(7, 2);
  System.out.println("Change in Share Price: " );
  System.out.println("Closing price per share: " + portfolio.getPricenorm()+ " " + portfolio.getPrice8th());
  System.out.println("Closing Portfolio Value: ");
  }}
  </code></pre>
  
  <p>And these are my results for what i get so far </p>
  
  <p>"Company: The Ramjac Corporation</p>
  
  <p>Shares Held: 100</p>
  
  <p>Opening price per sale: 37 0</p>
  
  <p>Change in Share Price: </p>
  
  <p>Closing price per share: 44 2</p>
  
  <p>Closing Portfolio Value: "</p>
  
  <p>Mind, i'm just starting programming and dont know much.</p>
  
  <p>Also, another quick question, how do i reduce the amount of characters in a number so i could make the result come out as dollars and cents and not come out as $100.5 or 100.50452 for example but make it come out with only $100.50.</p>