So I'm missing something here. I have a method that is supposed to compute and return the value of a stock portfolio. but it uses a mixed number which has a dollars portion and an eighths portion
public class StockPortfolio
{
//Instance Vars
private String company;
private int numOfShares;
private int dollarSharePrice;
private int eighthsSharePrice;
public int portfolioValue()
{
int portVal = (dollarSharePrice * numOfShares)
+ (eighthsSharePrice * numOfShares) / 8;
System.out.printf("Opening portfolio value: $%.2f" , portVal);
return portVal;
}
For the test class the values are 100
for numOfShares
, 37
for dollarSharePrice
and 5
for eighthsSharePrice
.
The expected output should look like this:
Opening portfolio value: $3762.50
my real trouble is just get the .50 to print. I've tried using % in different ways but to no avail. any help pointing me in the right direction is appreciated. I am at my wits end here.