Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please do not answer this question with an offer to do the answer in exchange fo

ID: 3540264 • Letter: P

Question

Please do not answer this question with an offer to do the answer in exchange for paypal payment.

There are TWO parts of one question to answer. Please answer BOTH TWO SUBPARTS of the question in order to get FULL 3000 points.

Question 1)

PART1) https://jumpshare.com/v/hscSaB26JmGhBRFmhhpq

Java Files you may need for Part 1) https://jumpshare.com/v/kr7gLjgWP62XaoByixmO

PART 2) https://jumpshare.com/v/erCGr9pgu4t8ThmjKfAb

Java Files you may need for Part 2) https://jumpshare.com/v/egSjwGJUuaoJxeiH6FFC

Explanation / Answer

Part1 :

//********************************************************************

// CheckParentheses.java

//

// Demonstrates other use of the StackList class from our Stack package

// implemented with our List class.

//********************************************************************



import MyStack.StackList;

import java.util.Scanner;


public class CheckParentheses

{

public static void main (String[] args)

{

Scanner scan = new Scanner (System.in);


StackList myStack = new StackList();


String expression, keep_going="y";

int index;

boolean properlyNested;


while (keep_going.charAt(0) == 'y' || keep_going.charAt(0) == 'Y')

{

System.out.print("Enter an arithmetic expression with parentheses");

Scanner s = new Scanner(System.in);

String str = s.nextLine();

int i = 0,flag = 0;

while(i<str.length()){

if(str.charAt(i) == '('){

myStack.push('(')

}

else if(str.charAt(i) == ')'){

if(myStack.empty()){

flag = 1;

break;

}

else{

myStack.pop()

}

}

if(flag == 0){

if(myStack.empty()){

System.out.print(str +" is properly nested with parentheses");

}

else{

System.out.print(str +" is NOT properly nested with parentheses");

}

}

else{

System.out.print(str +" is NOT properly nested with parentheses");

}

i++;

}



System.out.println(" ");

System.out.print("Want to continue with another expression? [y or n]: ");

keep_going = scan.nextLine();

}

}

}