Skip to content

⭐ Rated 4.9/5 by 8,400+ students  |  🎓 Expert writers in 80+ subjects  |  ✅ 100% original, no AI  |  🔒 Confidential & secure

Home Blog

The item at the top of the stack is

5 min read

Program 1Create a C# application for an integer stack. The program has the followingGUI:There are three buttons (Push, Pop and Clear) and one textbox. Wheneverthe user clicks the Push button, add a random integer at the top of the stack.This random integer can be as small as 0 and as large as 99. Whenever theuser clicks the Pop button, pop the stack (i.e. remove the item at the top) ifthe stack is not empty. Whenever the user clicks the Clear button, removeall items from the stack.The textbox always displays the content of the stack. When the programbegins to run, the textbox is empty because the stack is empty. Every timethe user clicks the Push, Pop or Clear button, update the content of thetextbox accordingly.The following is an example.Suppose the user clicks Push. A random integer is added to the stack.Suppose the user clicks Push again. Another random integer is added to thestack. Notice that the newly added integer is on top of the old integer.Suppose the user clicks Push again. Another random integer is added to thestack. Notice that the newly pushed integer again is on top of the oldintegers.Now suppose the user clicks Pop. The item at the top of the stack isremoved.Now suppose the user clicks Push. A random integer is added at the top ofthe stack.Now suppose the user clicks Clear. All items are removed from the stack.Hints: You can use the collection class Stack<T>. To display the content ofthe stack, use the ToArray method of the Stack class to convert the stack toan array and then use foreach (or a loop) to display every element in thearray.Grading:Creating GUI [10 points]Event handling for clicking the Push button [10 points]Event handling for clicking the Pop button [10 points]Event handling for clicking the Clear button [10 points]

Need help with your assignment?

Expert writers available now. Original work, no AI, free revisions.

🔒 No payment to start · Free revisions · Money-back guarantee

4.9 ★

Student rating

8,400+

Papers delivered

97%

On-time delivery

Why students choose Scholaris

  • 100% human writing, no AI
  • Plagiarism report with every order
  • Deadlines from 3 hours
  • Money-back guarantee
  • Free unlimited revisions

Related Study Guides