I am new to programming, so please accept my apologies if this question is simple.

My teacher wants us to create a method that searches a stack for the name that occurs most often and returns it

for example : If I have these names in my stack:

Tiger Woods, Jack Nicholas, Arnold Palmer, Jack Nicholas, Jimmy Demerrit, Jack Nicholas, Sam Sneed, Jimmy Demerrit, Ben Hogan, Walter Hagen, Tommy Armor, Bobby Jones

the method should return Jack Nicholas

Please help me for I need to know how to do it for my program

thank you in advance

Recommended Answers

All 4 Replies

so now is the time to plan your program and write some code. If you experience problems post the code snippet and someone will help you fix it.

I'm new to programming, can you please show an example

no, we would be violating forum rules.
you may want to take a close look at the first thread in this forum, it contains a lot of helpfull links and information to help you get started.

before writing code, come up with a plan of what you want to do, obviously theres no function that returns the value that comes back the most often in a list, otherwise it wouldnt be an assignement , so pick up and pen and paper, take your list, and find which name comes up the most often while writing everything you do in your head on the paper .

now you've got pseudocode, you can start writing code from that, or post your pseudocode here and ask us if the logic behind it is flawed, if it is, and we see it , we could save you some time trying to debug code that comes from flawed pseudocode.

Looking foward to see your pseudocode tomorrow morning, im going home for now, good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.