• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Help with my assignment

Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks, I am here again to see if you guys can help me with an assignment. I have came here for help before and you guys helped me immensely. I have this assignment:
A file containing information about fruits is structured as follows. <fruit>
<type> Apple </type>
<color> Green </color>
<color> Yellow </color>
<type> Banana </type>
The file consists of tags and data. An opening and closing tag pair, <tag> ... </tag>, define a particular data element. Each fruit has a type and a color. Notice that either may appear first within the <fruit> ... </fruit> tags. Your program should read a file called �fruit.txt� with the above structure.
The output of your program should be the number of each type of fruit, and the total pieces of fruit. For example, the output using the lines above is:
Number of type Apple: 1
Number of type Banana: 1
Total pieces of fruit: 2
Your program should be flexible enough to handle a file containing an indeterminate number of fruit descriptions. However, you may assume that there will be no more than 100 different types of fruit.

I am not asking anyone to do this for me, I know how this place works. I've been looking at the problem trying to figure out where to even start and I've hit a wall already. I was just wondering where I should start. I am awfully confused as to how to get it to read the file and then perform the operations required. What method should I use? Any hints will be great to get me rollin.
Thanks guys
This is where Im at so far ----->
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is an example here that might help you:

I didn't say it. I'm just telling you what this tiny ad said.
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic