New to Java, need help with arrays inside a loop please!
I'm coding a program that will take the prices entered by a user at a store and display them back within the program, so far I've completed the entire program except the part that takes the users input within a loops and prints it out as a array.
What I need help with;
The program has parameters whether ie. Adding anything over 3000 doesn't work, add a 0 removes the last price, and a -1 ends the program.
After ending the program (using -1) I need to take the prices the user input and output it within an array, example:
Enter a price for item #5: $-1
-1 entered, calculating total owing…
OK Gary, your purchases are:
I don't know how to code an array so I take reprint the prices entered by the user within the loop, if anyone could help me I'd be greatly appreciated.
Note: This is the array I created at the beginning of my program..
ArrayList <Double> costList = new ArrayList<Double>(15);
double  priceArray = new double ;
Re: New to Java, need help with arrays inside a loop please!
You mention array and yet in the code snippet you have an array and an ArrayList. Why?
You need a loop that reads in the user input and stores it in the array. After user enters -1 to end input you need another loop that iterates over the array and prints out each value. You can sum them up in the same loop.