Here is the question I am trying to answer....
Write a program that asks 3 people (include your first name and the first names of 2 other people) to enter the name of the stock purchased (for example, IBM, Google, Microsoft, Coca Cola), the number of shares of stock purchased, and the price per share of stock purchased. Each person must pay his or her stock broker a 2 percent (.02) commission for his or her stock transaction. Request the input data from each person by using the appropriate JOptionPane dialog box. Create a formula to calculate stock value (hint: stock price per share * number of stock shares purchased), commission (hint: stock value * .02), and total amount paid for the stock (hint: stock value plus commission). Using the appropriate JOptionPane dialog box, display 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.
So I have gotten where I can input all the information, but my problem is converting the Apple or Dell stock to an actual numerical value. So that I can multiply that value, by the amount purchased to figure out total spent on 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 StockCom = 0.00;
//Ask for First and Last name
String name = "";
String Firstname = JOptionPane.showInputDialog(
null, "Please enter your first name: ");
String 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);
String s3= JOptionPane.showInputDialog(null, "Number of Stock Purchased");