• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

How do I implement a function to count how many songs an artist has in Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I want to do is count how many songs an artist has within a text file of over 100,000 lines of different songs and different artists. For example: If I have 3 lines in the text file and all of them are by Elvis Presley it should have an output similar to this.


I've got it to do what I want up until that number part where it counts how many songs it's put out. If anyone could help me understand how I could implement this I'd be really appreciative.
 
Saloon Keeper
Posts: 4511
166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jacob,

Welcome to the Ranch and enjoy the stay!

Can you tell how far you have come? What kind of datastructure are you using?
 
Marshal
Posts: 7987
563
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jacob Segers wrote:What I want to do is count how many songs an artist has within a text file of over 100,000 lines of different songs and different artists. For example: If I have 3 lines in the text file and all of them are by Elvis Presley it should have an output similar to this.


I'm not clear about the data. It is a good example of poor data example as for the requirements.

What the output would be, if I'd add those 3 lines to the existing ones:
Sudegs tyloj | SEL
Blue Moon of Kentucky | Elvis Presley
Hound Dog | Elvis Presley

 
Marshal
Posts: 73021
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch (again)

What progress have you made? Assuming there are no misspelt versions of Elvis, how would you tell whether a song is his or not?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic