java - JOptionPane parsing arrays -
i new java , arrays. trying parse string input int , array. import javax.swing.joptionpane;
public class osl { string[] colortype = {"blue", "green", "white"}; final int colours = 3; // tshirt colours choices int[] color = new int[colours]; int order; public osl() { (int index = 0; index < colortype.length; index++) { string orderitems = joptionpane.showinputdialog("please enter number of t-shirts " + colortype[index]); int items = integer.parseint(orderitems); } (int index = 0; index < color.length; index++) { joptionpane.showmessagedialog(null, colortype[index] + ": " + color[index]); } } int orderitems; public int getorderitmes() { return orderitems; } public static void main(string[] args) { new osl(); } }
i can input integer not display them.
simply put, never apply quanity each color color
array in way. example, like...
for (int index = 0; index < colortype.length; index++) { string orderitems = joptionpane.showinputdialog("please enter number of t-shirts " + colortype[index]); int items = integer.parseint(orderitems); color[index] = items; }
which applies quantity user inputted each element in color
array
Comments
Post a Comment