Please do this part before doing the Part 1 in the Lab guide.
ArrayList<Customer> myList = new ArrayList<>();
Customer c1 = new Customer("Slim", "Dunlap", "K", "Jr.");
myList.add(c1);
// retrieve String from user
System.out.print("Enter a string: ");
String input = scanner.nextLine();
Before you loop through and process the input String, create an empty java.util.Stack<Character> and define an int initialized to zero which you can increment when your loop finds a nesting error.
for(int i=0; i<input.length(); i++)
{
char ch = input.charAt(i);
. . .
}
stack.push(ch);
To retrieve the top Character on the stack and access its char value, use code like:
char found = stack.pop();
switch (found)
{
case ')':
if (ch != '(')
{
errorCount++;
System.out.println("Error: expected '(', found " + found);
}
. . .
}
System.out.println(list);