Quote:
|
Originally Posted by MisterX
feast your eyes on 31 errors of pure Java!
public class SellStock
{
public SellStock()
{
price = 0;
numbers = 0;
value = 0;
commission = 0;
rate = 0;
proceeds = 0;
}
public void addPrice(double count)
{
price = price + count;
}
public void addNumbers(int count)
{
numbers = numbers + count;
}
public void addRate(double count)
{
rate = rate + count;
}
public void addValue()
{
value = price * numbers
}
public void addCommission (double rate)
{
commission = value * (rate/100);
}
public double getProceeds()
{
return value - commission;
}
}
public class SellStockTest
{
public static void main(String[] args)
{
SellStock iSellStock = new SellStock();
iSellStock.addPrice(10.125);
iSellStock.addNumbers(11);
iSellStock.addCommission(1.5);
double totalValue = iSellStock.getProceeds();
System.out.print("This program calculates the net proceeds from a sale of stock to be:");
System.out.println(getProceeds);
}
}
|
SellStock should not be a public class, only class. You cannot have two public classes declared in the same file.
Next, missing a semicolon on in the addValue() function.
Finally, getProceeds in println is a function so getProceeds()
I'll check for logic errors next, but those are the syntax.
Hope that helps.
Going on to some logic / style issues.
Firstly, dont always name variables count. Good practices mean using descriptive variables, also in Java, set and get are the terms used in code, not usually add.
The program was meant to take input from a terminal window according to the description, are you just testing the class itself before implementing a user input?