• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with my assignment

 
Greenhorn
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>
</fruit>
<fruit>
<color> Yellow </color>
<type> Banana </type>
</fruit>
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 ----->
 
Greenhorn
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:
http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html

Regards,
TY.
 
reply
    Bookmark Topic Watch Topic
  • New Topic