I need get users number of items, the prices, and print the prices like a receipt. Next I have to print out the subtotal, tax = .07
and the total.
I have tried using a for loop to get the info to add in the array. I have now tried the while loop.
Scanner sc = new Scanner(System.in);
double SubTot = 0;
//double numItmes = 0;
int numItems = Integer.parseInt(JOptionPane.showInputDialog("Enter the number of items: "));
double[] items = new double[numItems];
items[numItems] = Double.parseDouble(JOptionPane.showInputDialog("Enter the prices: "));
double i = 0;
while(i<numItems){
items[numItems]= sc.nextInt();
i++;
}
System.out.println("Here is the current list: \n" + Arrays.toString(items));
// double total = 0;
//double tax = 0.07;
JOptionPane.showMessageDialog(null,"The Sub Total is: " + SubTot + "The Tax is" + tax + "\n The Totoal is" + total);
}
>
My problem is getting the added array to spit out in consecutive lines. Also my tax is not being added to my total, or being multiplied by the subtotal. It keep posting the subtotal as 0 tax as .07 and total 0. What am I supposed to do?
*first time Java User. New programmer. Constructive criticism welcome