Sale!

Assignment 5 CSC300 solved

$30.00 $18.00

Original Work ?

Download Details:

  • Name: AssignmentFive-ddnlpa.zip
  • Type: zip
  • Size: 137.10 KB

Category: Tags: , You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Add the following methods to the Stack class (Stack.java):

1. A class method to display the contents of the stack from top to bottom.
2. A class method to display the contents of the stack from bottom to top.
3. An instance method called flip() that reverses the order of the stack elements.
4. An instance method called itemA(int n) that returns the element that is n from the top without changing the stack contents.

Write a new driver class that demonstrates these new methods.

Sample Run:

Testing the flip method…
Let’s push some items onto the stack:
pushing 20
pushing 40
pushing 60
pushing 80
Let’s flip the stack now …
and print the stack from bottom to top …
80
60
40
20

Let’s flip it one more time …
and print it from top to bottom …
80
60
40
20

Now let’s print the element at n equals 2: 40
What about at n equals 100 ?
Error: 100 out of range.
Done!

Notes:

1. The program must compile without syntax errors; 50% of the assignment points will be deducted if your program does not compile, even if your program is “essentially” correct.
2. To get full credit for an assignment, your program must solve the assignment problem completely.
3. Please add comments to the source code. Your program should have a reasonable amount of comments.
4. At the very beginning of each file, there should be a block comment containing the student name, course number, and assignment number.
5. Follow the programming styles and guidelines discussed in class, such as using meaningful names for variables and camel case conventions for variables, classes, etc.
6. Using ChatGPT or any LLM is not allowed. Your code will be examined if written using an AI tool.
7. To submit your Java files on Moodle:
a. Create a folder with your last name.
b. Place your java files inside the folder.
c. Zip the folder.
d. Upload it to Moodle.