Coder Social home page Coder Social logo

pid-exercise-1's Introduction

Programming in Depth - Exercise 1 - XML

Imagine that you have a supply of protein bars and you want to present these bars to potential customers to make it easier for them to reach their nutritional goals. Some of them might be interested in eating as much protein as they can (bodybuilders, I guess) and some of them might be interested in eating carbohydrates as well and so on. Your job is to make an application that will assist the customers in choosing the right product. At your disposal you have the information about the protein bars represented in an XML file bars.xml.

Task

Write Java code with the following functionalities (text interface program as the IP project):
Extract the information from the XML file into a data structure of your choice.
After that give the user the ability to choose from the following options:

  • Show the name of all bars.
  • Sort bars based on highest protein content.
  • Sort bars based on highest fat content.
  • Filter bars which has less than "some number from the user" fiber and sort them from highest to lowest.
  • Find all protein bars with more than X protein reviewed by Y (X and Y should be entered from the user).

Open question

Imagine that you have a very large database, think millions of protein bars. How do you think that the memory will behave with the database if you save it in a data structure ? Are there any problems? If yes, then how do we fix it?
What is the best sort algorithm to be used here and what is its time complexity. Motivate!

XML file

The XML file structure looks similar to this:

<products>
    	<bar SN="VyfdmYr">
		<fett>27.19</fett>
		<energy>1288.07</energy>
		<kolhydrat>25.96</kolhydrat>
		<protein>39.49</protein>
		<fiber>44.04</fiber>
		<review>
			<reviewer personID="PJ8">
				<date>2014-02-11</date>
				<score>4</score>
			</reviewer>   
		</review>
	</bar>


	<bar SN="pQEk83O">
		<fett>6.14</fett>
		<energy>2426.02</energy>
		<kolhydrat>1.4</kolhydrat>
		<protein>23.45</protein>
		<fiber>17.21</fiber>
		<review>
			<reviewer personID="k6Y">
				<date>2000-10-09</date>
				<score>5</score>
			</reviewer>
			<reviewer personID="k6p">
				<date>2000-10-09</date>
				<score>5</score>
			</reviewer>
		</review>
	</bar>   
</products>

pid-exercise-1's People

Watchers

Raja Umer Saghir avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.