Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Stock Profit calculator Issues

843789Jan 30 2010 — edited Jan 30 2010
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2010
Added on Jan 30 2010
6 comments
153 views