Assignment-05

 

 

 

Foreword

Resources

Code Listings

Foil Sets

Assignments

Solutions

External Resources

SiteMap

Search

Home

Up ] Assignment-01a ] Assignment-01b ] Assignment-01c ] Assignment-01d ] Assignment-02 ] Assignment-02a ] Assignment-03 ] Assignment-03a ] Assignment-03b ] Assignment-03c ] Assignment-03d ] Assignment-04 ] Assignment-04a ] Assignment-04b ] [ Assignment-05 ] Assignment-06 ] Assignment-07 ]

Writing a Java applet that uses data from a file

  1. You may choose to design your own applet that reads file data from the web server host and uses it in an application. This should either use the StreamTokenizer class on both word and number token types, or otherwise make use of individual characters or tokens in the file. (That is, it's not o.k. to just display the contents of the file without a significant computation or display.)
  2. or try the following applet:

    The Company Products Display

    Suppose that a company has a file with a product listed on each line. (Of course, they'ld really have a database, but that's another story!) Each product, or item in the file, should have a number of attributes. For example, suppose that it is a grocery store, and the file has entries where each item has a product code, a name, and a price:

            0019  apple    0.19
            1023  green beans   0.99
    

    Further suppose that the different types of groceries had product codes that started with different digits, such as all fruit had a number less than 1000, all vegetables had a number from 1000 up to 2000, and so on.

    Then you could write an applet that reads the contents of the file into a set of arrays, using StreamTokenizer to find the number and word tokens. And you could have an interface where customers could select the types of products that they wanted to view. At each selection, you would find all the products of that type in the arrays and display them in the applet.