*
The moose likes Beginning Java and the fly likes Finding best deal of mall program in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Finding best deal of mall program in java" Watch "Finding best deal of mall program in java" New topic
Author

Finding best deal of mall program in java

Vivek Jain
Ranch Hand

Joined: Oct 17, 2007
Posts: 34
Can anyone provide me this program?

Write a program to find best deal on a product in a shopping mall. Shops carry different products at different prices.

Main Requirements:
1.Mall data should be defined and read from an xml/flat file.
2.Allow entering product name on command line to find the best deal.
3.Print the store name, product name, and the price as a result on the console.
4.Program should continue with a prompt for the next product name. Word END should end the program.

Thanks in Advance!
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by free phone:
Can anyone provide me this program? ...

No. But we can help you write it. What have you done so far, and where are you stuck?

("free phone," welcome to JavaRanch! Please check your private messages by clicking on My Private Messages. Thanks!)
[ October 17, 2007: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Vivek Jain
Ranch Hand

Joined: Oct 17, 2007
Posts: 34
I've created XML file which conains data as shown below:
<Walmart>
<ProdInfo name="Shirt" price="$45">
<ProdInfo name="Pant" price="$45">
</Walmart>
<Kohls>
<ProdInfo name="Shirt" price="$35">
<ProdInfo name="Coat" price="$65">
</Kohls>

Now, I really don't know how to store them & how to compare for least values. Whether I should save them in hastable with Walmart_Shirt as key & value as its price for all the nodes, or how should I proceed?

Thanks!
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Instead of thinking about how to do it, think about what you want it to do first. That is, write some code that calls methods that don't exist yet and imagine how it would work. Maybe:

That gives some strong hints about how findBestPrice should work. You could make a first version that just says:

Seriously, make a test class and a Mall class that do no more than that. Show us what you make. Then we'll take the next step. This is a lot more fun than designing and writing hundreds of lines of code before you try and see how it works. Take tiny steps, keep it fun.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3700
    
    5

"John Machlane"

Please review our naming policy again. In short, you may not pick names that are obviously fictiuous (yes, we've all see Die Hard).


My Blog: Down Home Country Coding with Scott Selikoff
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

"John" - Your name is still not according to the JavaRanch policy.

Please check your private messages. You can see them by clicking My Private Messages.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Sankari Palani
Greenhorn

Joined: Nov 17, 2011
Posts: 1
Basic requirements:
Write your code in Java.
Program should run from command line.
There is no need to develop any GUI components, unless you think we will be impressed by it.


Problem
Write a program to find best deal on a product in a shopping mall. Shops carry different products at different prices.

Main Requirements:
1. Mall data should be defined and read from an xml/flat file.
2. Allow entering product name on command line to find the best deal.
3. Print the store name, product name, and the price as a result on the console.
4. Program should continue with a prompt for the next product name. Word END should end the program.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is the answer




Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37874
    
  22
Welcome to the Ranch

In view of this:
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
. . . which is written at the top of this page, I would usually delete that solution. But after 4 years, maybe I can safely leave it. Please don’t post complete solutions again.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37874
    
  22
Just looking at your code, I can see some things I would change:
  • use of System.exit()
  • Indentation: you are using tab and space together. Always use spaces.
  • It looks a lot better (as you can see now I have changed it) if you use the code button Only there appears to be a fault which occasionally changes < to ><. Don’t know why.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Finding best deal of mall program in java
     
    Similar Threads
    Mumbai - Best Mall
    Oracle to change Sun Certification names
    WA #1.....word association
    Factory Homes Assignment
    PreAssessment Questions and Answers