asgmt01/.classpath
asgmt01/.project
asgmt01
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
asgmt01/.settings/org.eclipse.jdt.core.prefs
#Thu Jul 08 18:02:33 PDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
asgmt01/amazon.txt
seattle amazoncom is expected to report its first profit this week
a pro forma operating one that excludes many costs but is nonetheless
seen by wall street as an important sign the online superstore can
eventually make real money
the company which is to report fourth quarter results tuesday is also
expected to show smaller net and operating losses the result of
stronger than expected holiday sales analysts said
seattle based amazon is expected to post a pro forma net loss of between
4 cents and 8 cents a share according to wall street tracking firm
thomson financial first call that compares to a loss of 25 cents a year
ago
that number includes interest payments which amount to $130 million a
year but not other costs like acquisition charges that are found in the
true net figure
while amazon is seen as still a long way from a net profit founder and
chief executive jeff bezos has promised to at least break even this
quarter on a pro forma operating basis
obviously its a pretty important quarter for the company i do think
theyll hit the target of a pro forma operating profit but i expect it
to be break even or for a slight profit said wr hambrecht analyst
kristine koerber
revenues are seen growing about 4 percent to $101 billion according
to first call many analysts think the strong holiday season means sales
could be higher with the top estimate being for $108 billion
this was the quarter that amazon had fine tuned its pricing and product
offering and with fairly low expectations we believe it could easily
beat the current estimates us bancorp piper jaffray analyst safa
rashtchy said in a research note
questions remain
amazon stock which started the year with a bang as holiday optimism
pushed the share price from single digits to more than $12 has slipped
since then though it rose more than 4 percent to close at $1016 on
friday
we believe amazon has entered the upward move having reached the
bottom both in its fundamentals and stock price rashtchy said
but wr hambrechts koerber said amazon still faced major challenges
namely how to rekindle falling ...
3. seattle based amazon is expected to post a pro forma net loss of
between
4 cents and 8 cents a share according to wall street tracking
firm
thomson financial first call that compares to a loss of 25 cents a
year
ago
that number includes interest payments which amount to $130
million a
year but not other costs like acquisition charges that are found
in the
true net figure
while amazon is seen as still a long way from a net profit
founder and
chief executive jeff bezos has promised to at least break even
this
quarter on a pro forma operating basis
obviously its a pretty important quarter for the company i do
4. think
theyll hit the target of a pro forma operating profit but i expect
it
to be break even or for a slight profit said wr hambrecht analyst
kristine koerber
revenues are seen growing about 4 percent to $101 billion
according
to first call many analysts think the strong holiday season
means sales
could be higher with the top estimate being for $108 billion
this was the quarter that amazon had fine tuned its pricing and
product
offering and with fairly low expectations we believe it could
easily
beat the current estimates us bancorp piper jaffray analyst safa
rashtchy said in a research note
questions remain
5. amazon stock which started the year with a bang as holiday
optimism
pushed the share price from single digits to more than $12 has
slipped
since then though it rose more than 4 percent to close at $1016
on
friday
we believe amazon has entered the upward move having reached
the
bottom both in its fundamentals and stock price rashtchy said
but wr hambrechts koerber said amazon still faced major
challenges
namely how to rekindle falling sales in its core books music and
video
segment that still accounts for more than half its sales
and while it has had success with sales of electronics the
company is
struggling to nurture other new product lines like kitchen goods
and
6. tools
i still have concerns about the companys business model and
long term
profitability or lack thereof koerber said they are trying to gain
traction in these new areas and trying to revive the core
business they
have a lot going on
as its main business of selling goods online directly has come
under
pressure amazon has also branched into selling used items and
licensing its e commerce platform to retailers like toys r us and
target
those segments are only a small fraction of revenues but they
carry
very high profit margins and are seen as crucial to the companys
prospects of making profits over the long haul
7. as usual analysts will be listening carefully to see what amazon
says
about its current quarter and the coming year
for its first quarter amazon is expected to lose between 7 cents
and 12
cents a share on revenues of about $747 million for all 2002 it
is
seen losing between 23 cents and 49 cents a share with sales of
$336
billion according to first call
prior to 2001 it was all about growth at the expense of profits
and
last year was about profits at the expense of growth i think this
year
they will try to find a balance said jeetil patel an analyst with
deutsche bank alex brown
story copyright 2002 reuters limited all rights reserved
8. ---
asgmt01/asgmt01.html
CS261 Assignment 1 Instructions
Code To Start With
This assignment provides a you with a .zip file containing the
code you should start with. The .zip file will expand into a
folder that is set up to be both a BlueJ project and an Eclipse
project.
JAR Files
Java executables are packaged as JAR (Java ARchive) files. A
JAR file is actually a Zip file. You can open a JAR file with any
Zip utility (e.g. 7-Zip). Once you’re ready to submit your work,
you will need to create a JAR file containing your code. Both
BlueJ and Eclipse have the ability to do this (see the How To
Create a JAR File... sections below). In order for your work to
be graded, your JAR file must be executable from the command
line.
Each JAR file contains a folder named META-INF. This folder
contains a file named MANIFEST.MF, which is the JAR file’s
“manifest file.” The manifest file is a text file that specifies
which Java class in the JAR file contains the main() method.
The Java Virtual Machine needs this information in order to be
able to run your code from the command line.
You should not change the structure of your project folder in
any way. Do not rename files, do not move files to a different
folder, do not create new folders or files, etc.
Collections Framework
If you do this assignment correctly, you will not have to
write a lot of code. You will just have to use
the Collections Framework intelligently. “Intelligently”
9. also means that
you should pay attention to the storage and time efficiency
of
your code and use the Collections
Framework
components that are most appropriate to the task your code
will be performing.
You are required to use the “generics” syntax in your code. This
means that if you’re using (for example) an ArrayList, you
should code it like this:
List<Integer> list = new ArrayList<Integer>();
In other words, the data types of the items in your Collections
must always be specified between the angle brackets.
This requirement is true of all other Java assignments for this
course. Anytime it’s possible to use the generics syntax, it’s
required.
Starting with the BlueJ/Eclipse project in asgmt01.zip:
Use the Collections Framework to write a program that
counts how many
times each word pair appears in a text file. A word pair
consists of two consecutive words (i.e. a word and the word that
directly follows it). In the first sentence of this paragraph, the
words “counts” and “how” are a word pair with a first word of
“counts” and a second word of “how.”
For instance, this input to the program:
abc def abc ghi abc def ghi jkl abc xyz abc abc abc ---
Should produce this output:abc:
abc, 2
def, 2
ghi, 1
xyz, 1
def:
10. abc, 1
ghi, 1
ghi:
abc, 1
jkl, 1
jkl:
abc, 1
xyz:
abc, 1
Note that the word “---” is used as an end-of-input marker, and
is not counted as a word.
Note that the list of words and each sublist of second words
is in alphabetical order. Putting things in alphabetical order is a
requirement of the assignment. Do not write your own code for
putting
the output into alphabetical order. Use the facilities
provided in the Collections Framework for that.
The output indicates that the word “abc” was followed twice by
“abc,” twice by “def,” once by “ghi,” and once by “xyz.” The
word “ghi” was followed once by “abc” and once by “jkl.”
Note that the output should be sorted by first word, and for each
first word the output should be sorted by second word.
To get full credit for this assignment, you should process the
words in one pass (i.e. just go through the words one time).
What you do to produce the printed output does not count as a
“pass.”
Do not bother with punctuation. Count words like “this.” and
“this” as separate
words. Do the same with capital and small letters (i.e.
“this” and “This” are separate words). For the purposes of this
assignment, any sequence of non-whitespace characters is
considered to be a word.
Submit your work as asgmt01.jar.
11. Using amazon.txt as its input, your progam should produce
output identical to the contents of asgmt01.output.txt, which is
provided with this assignment.
Testing Your Code
I will be using the file amazon.txt to test your code. The
amazon.txt file is included in asgmt01.zip.
In order to use amazon.txt as the input to your program, type
the
following at the MS-DOS command line:
java -jar asgmt01.jar < amazon.txt
By doing this, you will be “redirecting” the “standard input” of
your program to be amazon.txt, and
the input will come from amazon.txt instead of user type-in.
You do not need to write code for opening and reading the
amazon.txt file. Either do the “redirecting” as described
above or specify the file name as a command line argument to
main().
Required JAR File Structure
Here is the required structure for the .jar file that you will
submit for this assignment:
.jar file
Assignment1.javaAssignment1.class
META-INF
MANIFEST.MF
your source file
your compiled code
12. (folder)
manifest file created by your IDE – specifies the class
containing the main() method
You can use any Zip utility (e.g. 7-Zip) to check the structure of
your .jar file.
How To Create a JAR File in BlueJ
To create a .jar file from a BlueJ project, do the
following:“Project” menu, “Create Jar File ” command (was
“Export...” in older versions of BlueJ) choose “Store as jar
file”main class: choose the class that defines the main
methodcheck “include source” (if you don’t do this, your .java
files will not be included and your work will not be graded)
click “Continue”choose a name and a place for the JAR file
How To Create a JAR File in Eclipse
To create a .jar file from an Eclipse project, do the following:in
the Project Explorer view, click the small triangle to the left of
your project, which will open an outline viewright click on the
.jardesc (JAR DESCription) fileclick on “Create JAR”
The .jar file will be created in your project folder. Each
assignment project for this course will include a .jardesc file.
To Submit This Assignment
Submit the requested file to Desire2Learn. Make sure that your
13. code prints your name, assignment description, and number, as
requested. Be certain to check that you completed the upload
successfully. After you click the Upload File button, you must
also click the SUBMIT ASSIGNMENT button. This is very
easy to forget. If you do not do this, I will not see your work
and you will get a grade of zero for the assignment. I would
recommend entering an email address so you can be notified
that the upload was completed successfully.You may upload as
many versions as you wish prior to the due date. I will only see
and grade the final one. You will not be able to upload
assignments after due date.Points will be deducted for
uploading a file with a name that is not as specified. Every term
I get a few students whose approach to following directions is,
shall we say, “creative.” I encourage creativity in general, but
there are places where it is not appropriate.
asgmt01/asgmt01.jardesc
asgmt01/asgmt01.output.txtCS261 - Assignment 1 - Mike
Noel$101: billion 1$1016: on 1$108: billion 1$12: has
1$130: million 1$336: billion 1$747: million 112: cents
12001: it 12002: it 1 reuters 123: cents 125: cents 14:
cents 1 percent 249: cents 17: cents 18: cents 1a: balance
1 bang 1 long 1 loss 1 lot 1 net 1 pretty 1 pro 4
research 1 share 3 slight 1 small 1 year 2about: $747 1
4 1 growth 1 its 1 profits 1 the 1according: to 3accounts:
for 1acquisition: charges 1ago: that 1alex: brown 1all:
2002 1 about 1 rights 1also: branched 1 expected 1amazon:
had 1 has 2 is 3 says 1 still 1 stock 1amazoncom: is
1amount: to 1an: analyst 1 important 1analyst: kristine 1
safa 1 with 1analysts: said 1 think 1 will 1and: 12 1 49
1 8 1 are 1 chief 1 last 1 licensing 1 long 1 operating 1
product 1 stock 1 target 1 the 1 tools 1 trying 1 video 1
while 1 with 1are: found 1 only 1 seen 2 trying 1areas:
14. and 1as: an 1 crucial 1 holiday 1 its 1 still 1 usual 1at:
$1016 1 least 1 the 2balance: said 1bancorp: piper 1bang:
as 1bank: alex 1based: amazon 1basis: obviously 1be:
break 1 higher 1 listening 1beat: the 1being: for 1believe:
amazon 1 it 1between: 23 1 4 1 7 1bezos: has 1billion:
according 2 this 1books: music 1both: in 1bottom: both
1branched: into 1break: even 2brown: story 1business:
model 1 of 1 they 1but: i 1 is 1 not 1 they 1 wr 1by:
wall 1call: many 1 prior 1 that 1can: eventually 1carefully:
to 1carry: very 1cents: a 4 and 3challenges: namely
1charges: that 1chief: executive 1close: at 1come: under
1coming: year 1commerce: platform 1company: i 1 is 1
which 1companys: business 1 prospects 1compares: to
1concerns: about 1copyright: 2002 1core: books 1 business
1costs: but 1 like 1could: be 1 easily 1crucial: to
1current: estimates 1 quarter 1deutsche: bank 1digits: to
1directly: has 1do: think 1e: commerce 1easily: beat
1electronics: the 1entered: the 1estimate: being 1estimates:
us 1even: or 1 this 1eventually: make 1excludes: many
1executive: jeff 1expect: it 1expectations: we 1expected:
holiday 1 to 4expense: of 2faced: major 1fairly: low
1falling: sales 1figure: while 1financial: first 1find: a
1fine: tuned 1firm: thomson 1first: call 3 profit 1 quarter
1for: $108 1 a 1 all 1 its 1 more 1 the 1forma: net 1
operating 3found: in 1founder: and 1fourth: quarter
1fraction: of 1friday: we 1from: a 1 single 1fundamentals:
and 1gain: traction 1going: on 1goods: and 1 online
1growing: about 1growth: at 1 i 1had: fine 1 success
1half: its 1hambrecht: analyst 1hambrechts: koerber 1has:
also 1 come 1 entered 1 had 1 promised 1 slipped 1haul:
as 1have: a 1 concerns 1having: reached 1high: profit
1higher: with 1hit: the 1holiday: optimism 1 sales 1
season 1how: to 1i: do 1 expect 1 still 1 think
1important: quarter 1 sign 1in: a 1 its 2 the 1 these
1includes: interest 1interest: payments 1into: selling 1is:
also 1 expected 3 nonetheless 1 seen 2 struggling 1 to
15. 1it: could 1 has 1 is 1 rose 1 to 1 was 1items: and 1its:
a 1 core 1 current 1 e 1 first 2 fundamentals 1 main 1
pricing 1 sales 1jaffray: analyst 1jeetil: patel 1jeff: bezos
1kitchen: goods 1koerber: revenues 1 said 2kristine:
koerber 1lack: thereof 1last: year 1least: break 1licensing:
its 1like: acquisition 1 kitchen 1 toys 1limited: all 1lines:
like 1listening: carefully 1long: haul 1 term 1 way 1lose:
between 1losing: between 1loss: of 2losses: the 1lot: going
1low: expectations 1main: business 1major: challenges
1make: real 1making: profits 1many: analysts 1 costs
1margins: and 1means: sales 1million: a 1 for 1model:
and 1money: the 1more: than 3move: having 1music: and
1namely: how 1net: and 1 figure 1 loss 1 profit 1new:
areas 1 product 1nonetheless: seen 1not: other 1note:
questions 1number: includes 1nurture: other 1obviously: its
1of: $336 1 25 1 a 1 about 1 between 1 electronics 1
growth 1 making 1 profits 1 revenues 1 selling 1 stronger
1offering: and 1on: a 1 as 1 friday 1 revenues 1one: that
1online: directly 1 superstore 1only: a 1operating: basis 1
losses 1 one 1 profit 1optimism: pushed 1or: for 1 lack
1other: costs 1 new 1over: the 1patel: an 1payments:
which 1percent: to 2piper: jaffray 1platform: to 1post: a
1pressure: amazon 1pretty: important 1price: from 1
rashtchy 1pricing: and 1prior: to 1pro: forma 4product:
lines 1 offering 1profit: but 1 founder 1 margins 1 said 1
this 1profitability: or 1profits: and 1 at 1 over 1promised:
to 1prospects: of 1pushed: the 1quarter: amazon 1 and 1
for 1 on 1 results 1 that 1questions: remain 1r: us
1rashtchy: said 2reached: the 1real: money 1rekindle:
falling 1remain: amazon 1report: fourth 1 its 1research:
note 1result: of 1results: tuesday 1retailers: like 1reuters:
limited 1revenues: are 1 but 1 of 1revive: the 1rights:
reserved 1rose: more 1safa: rashtchy 1said: amazon 1 but 1
in 1 jeetil 1 seattle 1 they 1 wr 1sales: analysts 1 and 1
could 1 in 1 of 2says: about 1season: means 1seattle:
amazoncom 1 based 1see: what 1seen: as 2 by 1 growing
16. 1 losing 1segment: that 1segments: are 1selling: goods 1
used 1share: according 1 on 1 price 1 with 1show:
smaller 1sign: the 1since: then 1single: digits 1slight:
profit 1slipped: since 1small: fraction 1smaller: net
1started: the 1still: a 1 accounts 1 faced 1 have 1stock:
price 1 which 1story: copyright 1street: as 1 tracking
1strong: holiday 1stronger: than 1struggling: to 1success:
with 1superstore: can 1target: of 1 those 1term:
profitability 1than: $12 1 4 1 expected 1 half 1that:
amazon 1 are 1 compares 1 excludes 1 number 1 still
1the: bottom 1 coming 1 company 3 companys 2 core 1
current 1 expense 2 long 1 online 1 quarter 1 result 1
share 1 strong 1 target 1 top 1 true 1 upward 1 year
1then: though 1thereof: koerber 1these: new 1they: are 1
carry 1 have 1 will 1theyll: hit 1think: the 1 theyll 1
this 1this: quarter 1 was 1 week 1 year 1thomson:
financial 1those: segments 1though: it 1to: $101 1 $130 1
2001 1 a 1 at 1 be 1 close 1 find 1 first 2 gain 1 lose
1 more 1 nurture 1 post 1 rekindle 1 report 2 retailers 1
revive 1 see 1 show 1 the 1 wall 1tools: i 1top: estimate
1toys: r 1tracking: firm 1traction: in 1true: net 1try: to
1trying: to 2tuesday: is 1tuned: its 1under: pressure
1upward: move 1us: and 1 bancorp 1used: items 1usual:
analysts 1very: high 1video: segment 1wall: street 2was:
about 1 all 1 the 1way: from 1we: believe 2week: a
1what: amazon 1which: amount 1 is 1 started 1while:
amazon 1 it 1will: be 1 try 1with: a 1 deutsche 1 fairly
1 sales 2 the 1wr: hambrecht 1 hambrechts 1year: ago 1
but 1 for 1 they 1 was 1 with 1bye...
asgmt01/Assignment1.ctxt
#BlueJ class context
comment0.params=args
comment0.target=void main(java.lang.String[])
17. numComments=1
asgmt01/Assignment1.javaasgmt01/Assignment1.javaimport jav
a.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
// By default, this code will get its input data from the Java stan
dard input,
// java.lang.System.in. To allow input to come from a file instea
d, which can be
// useful when debugging your code, you can provide a file nam
e as the first
// command line argument. When you do this, the input data will
come from the
// named file instead. If the input file is in the project directory,
you will
// not need to provide any path information.
//
// In BlueJ, specify the command line argument when you call m
ain().
//
// In Eclipse, specify the command line argument in the project'
s "Run Configuration."
publicclassAssignment1
{
// returns an InputStream that gets data from the named file
privatestaticInputStream getFileInputStream(String fileName)
{
InputStream inputStream;
18. try{
inputStream =newFileInputStream(newFile(fileName));
}
catch(FileNotFoundException e){// no file with this name exists
System.err.println(e.getMessage());
inputStream =null;
}
return inputStream;
}
publicstaticvoid main(String[] args)
{
// Create an input stream for reading the data. The default is
// System.in (which is the keyboard). If there is an arg provided
// on the command line then we'll use the file instead.
InputStream in =System.in;
if(args.length >=1){
in = getFileInputStream(args[0]);
}
// Now that we know where the data is coming from we'll start p
rocessing.
// Notice that getFileInputStream could have generated an error
and left "in"
// as null. We should check that here and avoid trying to proces
s the stream
// data if there was an error.
if(in !=null){
// Using a Scanner object to read one word at a time from the in
put stream.
19. Scanner sc =newScanner(in);
String word;
System.out.printf("CS261 - Assignment 1 - Your Name%n%n");
// Continue getting words until we reach the end of input
while(sc.hasNext()){
word = sc.next();
if(!word.equals("---")){
// do something with each word in the input
// replace this line with your code (probably more than one line
of code)
System.out.println(word);
}
}
System.out.printf("%nbye...%n");
}
}
}
asgmt01/package.bluej
#BlueJ package file
package.editor.height=258
package.editor.width=339
package.editor.x=30
package.editor.y=58
package.numDependencies=0