Hi,
Yes, I am sure you can tell that I am new. I have a few question and hope someone will answer them. 1)I am a little confused as to where to put certain code. If I am doing inventory and I need to have an array does it go into a separate class? I need one class that just displays everything. I am not sure how to go about it and have been doing the tutorials at Oracle but still I remain confused. I would like someone to explain it without using a lot of tech terms if that is possible. 2) This is the code I have so far. The problem is when it prints the total stock value is right next to the price and not legible. I am at a loss as to how to format an array. 3)Does this satisfy having an array to show one product at a time? I appreciate any guidance that would be offered. I have read tutorials,watched tutorials and it is as if I understand a different language.
Thank you,
lynnajoe
package inventory23;
import java.text.*;
/**
*
* @author Lynnajoe
*/
public class inventory23 {
private static int numInStk;
private static int Quantity;
private static double totalStkValue =numInStk*Quantity;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String[]headings;
headings = new String [1];
headings[0]]= "Name";
System.out.printf("%s %9s %5s %8s %22s","Product","Stock#","Qty","Price","Total Stock Value\n");
String []anArray;
anArray = new String [4];
anArray [0] = "Cabernet 01 5 14.99" + totalStkValue;
anArray [1] = "Chardonnay 02 8 12.99" + totalStkValue;
anArray [2] = "Merlot 03 10 11.99" + totalStkValue;
anArray [3] = "Cola 04 5 6.99" + totalStkValue;
System.out.println(""+ anArray[0]);
System.out.println(""+ anArray[1]);
System.out.println(""+ anArray[2]);
}
}