Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i just want UML for this code please quickly Here is the output of Stackofintegers program: 9 8 7 6 5 4 3 2 1

i just want UML for this code please quickly image text in transcribed
image text in transcribed
Here is the output of Stackofintegers program: 9 8 7 6 5 4 3 2 1 2 Exercise - StackOfStrings Class: Design a class named Stackofstrings that contains: a. A private array elements to store strings in the stack b. A private data field size to store the number of strings in the stack c. A constructor to construct an empty stack with a default capacity of 4 d. A constructor to construct an empty stack with a specified capacity e. A method empty() that returns true if the stack is empty f. A method push(String value) that stores value at the top of the stack. This method checks if the stack is full before pushing to it. In case the stack is full, it 1. copies the contents of the stack to a new temp array ii. creates a new elements array with double the current capacity iii. copies back temp to elements iv. places value at the top of the new stack g. A method pop() that removes the string at the top of the stack and returns it. In case the stack is empty, it returns "Stack is EMPTY" h. A method peek() that returns the string at the top of the stack without removing it from the stack. In case the stack is empty, it returns "Stack is EMPTY" I. A method printStack() as shown below: SEGONS public void printStack(){ System.out.print("Stack (top to bottom): "); for (int i=size-1; i>-1; i--) System.out.print(elements[i] + " "); System.out.printin(); 1. Draw the UML diagram for the Stackofstrings class. 2. Implement the StackOfStrings class. 3. Use the test program shown on the following page which creates a Stackofstrings object, and then allows the user to push, pop or peek at the stack. 4. Draw the UML diagram for the Stackofstrings object created in the test program. import java.util.Scanner; public class Test public static void main(String[] args) { Stackofstrings stack = new Stackofstrings(); System.out.println("STACK OF STRINGS Type PSH followed by a space + "and a string and a carriage return or Type POP followed" + "by a carriage return or Type PEK followed by a carriage + "return or Type STP followed buy a carriage return"); STUDENTS Scanner input = new Scanner(System.in); while (true) System.out.print("Enter command: "); Strings = gs = input.nextLine(); String stackCommand = s.substring(0,3); switch (stackCommand) { case "PSH": stack.push(s.substring(s.indexOf(" ") + 1)); stack printStackli

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Know the principles of effective service recovery systems.

Answered: 1 week ago

Question

Explain the service recovery paradox.

Answered: 1 week ago