Results 1 to 5 of 5
  1. #1
    zorroforce is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Exclamation Monitor Disc Head Using Java

    Pls help me to write a code for this appli. . I am new to java and have to do this program soon.
    Your program should follow the following algorithm:
    a) You are given a starting point for the disk head. (100)
    b) You will read a set of values representing the position of the disk head and place it in a table representing the trace of disk head movement during the retrieving process.
    c) For each disk head position read, calculate the number of tracks traversed
    d) At the end of your program, you should calculate the average tracks seek length which is the sum of the total number of traversed tracks.
    e) Your program should create an output file “output_lab3.txt” containing a table with 2 columns:
    a. First column: the value of the head position read
    b. Second column: The corresponding value of the number of traversed tracks.
    c. The last row of the table should have the average value of the number of traversed tracks.


    Access Request
    98
    183
    37
    122
    14
    124
    65
    67
    The average of tracks traversed is:

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Welcome to the forum.

    I'm afraid all you've done is post your assignment verbatim without showing that you've done any work. Many here will assume that by doing this you wish to have someone else do your work for you, and they will avoid helping your or answering your questions.

    I will assume that this is not what you intended with this post and will suggest that to increase your chances of getting help here you show us what you've done and then ask more specific questions regarding problems with your code.

    Again welcome, and much luck!

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    OK, so we now know that you can copy code from the internet, specifically here: Reading a file into java and give it out.

    I recommend that you have a look here: So, You Need to Write a Program but Don't Know How to Start. It's a very well written article, trust me.

    Again, much luck.
    Last edited by Fubarable; 09-13-2009 at 05:03 AM.

  4. #4
    zorroforce is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default

    This is the closest i can go ,pls




    public class mylist {

    public static void main(String args [] ) {
    int [] a = { 100,98,183,27,132,14,124,65,67 } ;
    int [] y = { 98,183,27,132,14,124,65,67, 00 } ;

    System.out.println ("Access Request # Tracks Transversed" );
    for
    ( int i=0 ;i<=a.length-1 ; i++ )
    for
    ( int j=0; j<=1 ; j++ )
    {
    if
    (j==0)

    { System.out.println ( a[i] );

    }
    if (j==1)
    {
    System.out.println( a[i] - y[i]);
    }
    }

    }
    }

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    First off, use [code][/code] tags around your code so we can read it.

    Secondly, you do not need two arrays to calculate the values in this problem, you only need the starting array and an array to store the differences. Everything else can be calculated on the fly.

    Finally, have you done this on paper step by step? The MUST be your first step before trying to think of any code. Once you have designed al algorithm by hand on paper in a human-readable (pseudo code if you like) way, then and only then try to code it.

    Lastly, if I understood the assignment correctly, your output should look something like this ?
    Java Code:
    100
    98        2
    183       85
    27        156
    132       105
    14        118
    124       110
    65        59
    67        2
    Avg: 79

Similar Threads

  1. printer monitor in java
    By sundarjothi in forum Advanced Java
    Replies: 1
    Last Post: 06-14-2008, 02:52 AM
  2. burn disc in Java
    By nancyhung in forum Advanced Java
    Replies: 1
    Last Post: 04-02-2008, 12:54 PM
  3. Java Application Monitor API 2.7
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 09-22-2007, 11:25 PM
  4. Java Application Monitor API 2.6
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-04-2007, 08:08 AM
  5. Java Application Monitor API 2.5
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-21-2007, 10:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •