Results 1 to 3 of 3
  1. #1
    case1001 is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default Help with creating a program

    Please help with this program. I have a problem designing the algorithms on bluej and i need to do it on bluej cause i want to learn to work on it. I randomly chose this program from the internet but it seems i'm doing something wrong. Please help.

    Part 1. (CAS 9-11) The basic classes and addSample method

    Create a class called Sample that has three fields representing the minute past midnight in the day that the sample was collected (an int expected to be in the range 0-1439), the location that the sample was collected from (a String) and the value of the sample (an int). These fields should be constants; i.e. their values should not change for the lifetime of the object. (We are assuming that the temperature sensors are accurate to within 1 degree.)
    Write a constructor for this class.
    Create a class called Analyser that uses Sample. The analyser should contain a collection of Sample objects.
    Within the Analyser class, write a constructor.
    Within the Analyser class, write a method with signature
    public void addSample(int time, String location, int value)
    This method should create a new Sample object and add it to the collection only if the value of the sample is greater than or equal to 0 (absolute zero!) and the minute in which it was taken is in the range 0-1439 (there are 1440 minutes in a day, and we are assuming that all samples are from a single day).
    Part 2. (CAS 12-14) Listing all samples

    Include this method in the Analyser class to populate the collection with a number of samples for testing purposes:
    * Populate collection
    public void populate()
    addSample(0, "Fraser Noble", 280); // 00:00 7C
    addSample(120, "Fraser Noble", 281); // 02:00 8C
    addSample(240, "Fraser Noble", 282); // 04:00 9C
    addSample(360, "Fraser Noble", 286); // 06:00 13C
    addSample(480, "Fraser Noble", 288); // 08:00 15C
    addSample(600, "Fraser Noble", 290); // 10:00 17C
    addSample(720, "Fraser Noble", 291); // 12:00 18C
    addSample(840, "Fraser Noble", 290); // 14:00 17C
    addSample(960, "Fraser Noble", 290); // 16:00 17C
    addSample(1080, "Fraser Noble", 289); // 18:00 16C
    addSample(1200, "Fraser Noble", 288); // 20:00 15C
    addSample(1320, "Fraser Noble", 283); // 22:00 10C NO FAULTS
    addSample(1600, "Fraser Noble", 288); // SHOULD NOT BE ADDED
    addSample(-600, "Meston", 290); // SHOULD NOT BE ADDED
    addSample(60, "Meston", 282); // 01:00 9C
    addSample(180, "Meston", 282); // 03:00 9C
    addSample(300, "Meston", 284); // 05:00 11C
    addSample(420, "Meston", 286); // 07:00 13C
    addSample(540, "Meston", 291); // 09:00 18C
    addSample(660, "Meston", 289); // 11:00 16C
    addSample(780, "Meston", 290); // 13:00 17C
    addSample(900, "Meston", 200); // 15:00 -73C
    addSample(1020, "Meston", 320); // 17:00 47C
    addSample(1140, "Meston", 290); // 19:00 17C
    addSample(1260, "Meston", 290); // 21:00 17C
    addSample(1380, "Meston", 290); // 23:00 17C SENSOR FAULT
    addSample(30, "MacRobert", 279); // 00:30 6C
    addSample(150, "MacRobert", 280); // 02:30 7C
    addSample(270, "MacRobert", 279); // 04:30 6C
    addSample(390, "MacRobert", 281); // 06:30 8C
    addSample(510, "MacRobert", 285); // 08:30 12C
    addSample(630, "MacRobert", 286); // 10:30 13C
    addSample(750, "MacRobert", 287); // 12:30 14C
    addSample(870, "MacRobert", 288); // 14:30 15C
    addSample(990, "MacRobert", 289); // 16:30 16C
    addSample(1110, "MacRobert", 287); // 18:30 14C
    addSample(1230, "MacRobert", 281); // 20:30 8C
    addSample(1350, "MacRobert", 277); // 22:30 5C HEATING FAULT
    addSample(1230, "MacRobert", -5); // SHOULD NOT BE ADDED
    Write a method that prints out all samples in the collection along with the location from which the sample was taken. For example, this method may print out the following:
    [Fraser Noble, 00:00] 280
    [Fraser Noble, 02:00] 280
    [Fraser Noble, 04:00] 280
    [Fraser Noble, 06:00] 280
    [Fraser Noble, 08:00] 280
    Hint: remember the % and / operators on ints.
    Part 3. (CAS 15-17) Highest temperature and faulty sensors

    Write a method that displays the highest temperature recorded.
    Write a method that displays the locations that have faulty sensors. A sensor is assumed to be faulty if it reports a temperature below 258 Kelvin or above 303 Kelvin. From the data above, this method should report that the Meston sensor is faulty.
    Part 4. (CAS 18-20) Faulty heating

    Add a new field in your Analyser class that is a collection of String. This will be used to record the locations of faulty sensors. Then write a new method (similar to that for part 3(b)) that populates this collection with the locations of faulty sensors. (Hint: have a look at java.util.HashSet.)
    Write a method that reports on buildings with faulty heating. The heating is faulty if the sensor is working correctly (i.e. it is not faulty) and the temperature reported in the building during working hours falls below 288K more than once. Assume that working hours are between 08:00 and 19:00.
    Fully document your code using Javadoc style.

  2. #2
    mwr1976 is offline Senior Member
    Join Date
    Oct 2011
    Rep Power

    Default Re: Help with creating a program

    As a rule someone is not going to hand you the code for an entire program. You should attempt it. Search the internet and the forums for an answer, then......Post and Explain exactly where you are stuck, and post and compiler errors. Make sure you use code tags.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

Similar Threads

  1. Help with creating a program
    By case1001 in forum New To Java
    Replies: 1
    Last Post: 11-28-2011, 01:16 AM
  2. need help creating a battleship like program
    By ss1 in forum New To Java
    Replies: 12
    Last Post: 08-19-2011, 12:00 AM
  3. I need help creating this program
    By LostinJavaLand in forum New To Java
    Replies: 14
    Last Post: 04-29-2010, 10:41 AM
  4. Need help creating this java program
    By SolidifieD in forum New To Java
    Replies: 1
    Last Post: 02-23-2010, 12:46 AM
  5. Creating Program Stubs
    By Bascotie in forum New To Java
    Replies: 2
    Last Post: 01-18-2009, 06:27 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