I am trying to make a comand line calculator that will calculate the profit from buying a stock at a certain price then selling it at another price.
Here is what I have so far.
package stockprofitcalc;
/**
*
* @author wolney1
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
throws java.io.IOException {
// TODO code application logic here
calcM stockCalc = new calcM();
stockCalc.calc();
}}
package stockprofitcalc;
/**
*
* @author billolney
*/
public class calcM {
float bPrice=0;
float sPrice=0;
float quantity=0;
float commision=40;
float profit=0;
public void calc()
throws java.io.IOException {
System.out.println("Buy Price:");
bPrice= (float) System.in.read();
System.in.read();
System.out.println("Sell Price:");
sPrice= (float) System.in.read();
System.in.read();
System.out.println("Quantity:");
quantity= (float) System.in.read();
System.in.read();
profit=(((sPrice-bPrice)*quantity)-commision);
System.out.println("Profit:" + profit);
System.out.println(commision);
}}
when I run it all the calculatons are wrong.
Bill