2 #Java Construct Week: Java Programs for Stack Operations and String Manipulation Project Overview This project contains Java implementations of two primary tasks:
- Removing vowels from a given string.
- Implementing a stack using an array. File Structure: Construct_Week/ │ ├── ArrayStack.java # Implementation of Stack using Array ├── Operations_on_Stack.java # Main ϐile to demonstrate Stack operations └── RemoveVowels.java # Program to remove vowels from a given string Task Details Question 1: Remove Vowels from a String Objective: Write a Java program that removes all vowels from a given string. Files Involved:
- RemoveVowels.java Functionality:
- The program prompts the user to enter a string.
- The vowels are removed from the string using a custom method.
- The modified string is displayed with all vowels removed. Sample Input and Output: Input: Enter a string: hello, world! Output: The string with vowels removed is: hll, wrld! Question 2: Implement a Stack using an Array Objective: Implement a stack using an array in Java with the following functionalities:
- push: Adds an element to the top of the stack.
- pop: Removes and returns the top element.
- peek: Returns the top element without removing it.
- isEmpty: Checks if the stack is empty. Files Involved:
- ArrayStack.java
- Operations_on_Stack.java Functionality:
- ArrayStack is the core class that defines the stack using an array.
- Operations_on_Stack.java demonstrates the stack operations such as push, pop, peek, and checking if the stack is empty. Sample Input and Output: Stack Operations:
- Push
- Pop
- Peek
- Check if Empty
- Exit Enter your choice: 1 Enter an element to push: 10 Element pushed successfully. Enter your choice: 1 Enter an element to push: 20 Element pushed successfully. Enter your choice: 3 Top element: 20 Enter your choice: 2 Popped element: 20 Enter your choice: 4 Stack is not empty. Enter your choice: 5 Exiting... Requirements
- Java Development Kit (JDK) installed.
- Basic understanding of Java programming concepts. How to Run the Project
- Clone the repository or download the project.
- Compile the .java files: javac RemoveVowels.java javac ArrayStack.java Operations_on_Stack.java
- Run the files: java RemoveVowels java Operations_on_Stack Author Muskan Patel