CSE 461 Homework 1
Due Friday October 9
Solution
The solution is divided into three files:
- GetQuoteInfo.java: Contains code
for parsing the HTML file and obtaining the stock price.
- DisplayMarketCap.java": Contains
code for displaying the market cap graphically.
- Main.java: Opens the URL connection and ties
everything up together.
The goal of the assignment is to get everyone started on writing,
compiling and testing Java programs. You have to write a program that
periodically outputs the market cap of Microsoft. The market cap
is defined as the product of the share price and the total number
of outstanding shares. The program would involve the following steps:
- Periodically, send a HTTP request to a web site which maintains
updated Microsoft stock quotes (for example,
http://quote.yahoo.com/q?s=msft&d=v1
). Parse the HTML file that you get to determine the quote.
- Obtain the number of outstanding shares. You could do this by sending
a request to http://biz.yahoo.com/p/m/msft.html. But using a constant value of 2.48B shares is acceptable since
the value remains static.
- Output the market cap. A simple text output is acceptable although you might
want to graphically plot the data for a more visually appealing effect. Using
the graphics is completely optional.
Some Useful Things
- Sending a HTTP Request:
See the class URLConnection
- Sleep: You need to periodically output data. For this your program needs to sleep.
You can use the sleep method in class Thread.
- Graphics: See the java.awt library.
Compiling and running in Visual J++
To compile and test your priority queue in Visual J++, you should
do the following:
- Create a workspace and a project.
- Save the java files and insert them in the project.
- Under
Project/Settings/Debug (i.e. the Debug pane of the
Project/Settings dialog), in the "General" category, change the radio
button to the choice for standalone application.
- Under Project/Settings/General, appropriately set the class path
and the output path.
- Build the project
- Run the project
Turnin
To turn in this assignment, please print out and hand in the following
- Your name
- A brief description of how you solved the problem, how you organized
your code, any special features that you added to the program, how robust
is your program, what you think is interesting about your solution.
A couple of sentences is
probably appropriate here, more than a couple of paragraphs is not.
What I'd like is enough of a roadmap so I'll know what to look for in
your code.
- The Java source code. Well documented code
is necessary for me to properly understand it.
- A transcript of the output you get from running your program
amit@cs.washington.edu