Need help with calculating stock code.
/*This program was written by **** March 20, 2012 for CISM **** to show each person’s name, name of stock he or she purchased, the stock value, the amount of the stock commission, and the total amount paid for the stock.
public class Stock
public static void main(String args)
int numberofShares = 0,priceperShare = 0,valueofShares=0;
double commission = 0.00, double totalStockcost = 0.00 double amtStockcommision = 0.00;
//Ask for First and Last name
String name = "";
First name = JOptionPane.showInputDialog(
null, "Please enter your first name: ");
LastName = JOptionPane.showInputDialog(
null, "Please enter your last name: "));
//Create list string to call later
String list =
"1 for Apple \n"+
"2 for Microsoft \n"+
"3 for DELL \n";
//Ask for the number corresponding to the Stock
String s2 = JOptionPane.showInputDialog(null, "Please pick a number corresponding to the stock that you bought: \n " + list);
stockNumber = Integer.parseInt(s1);
OK NEXT THING I WANT TO DO IS ASK HOW MUCH OF EACH STOCK SO IF THEY BUY 2 APPLE etc. how do i incorporate that??
Re: Need help with calculating stock code.
Add another call to JOptionPane with the text of the message you want shown to the user. Get the response and convert it to a number as you have done already for the stockNumber.
WANT TO DO IS ASK HOW MUCH