Results 1 to 12 of 12

Thread: Java methods

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Time Lord Member The_Doctor's Avatar
    Join Date
    Oct 2004
    Location
    The TARDIS
    Posts
    2,040

    Default Re: Java methods

    The size of the square goes up in standard increments?
    Yes.

    What was the exact design ? It can't be very long considering it's only one method, so you might as well share it with us
    Actually there where 4 methods, but they where pretty much the same.

    This is the design document:

    Shape Area Calculation Program

    Requirements Specification

    1. The program will continually display a menu to the user until the user chooses to quit. The menu choices are:

    1. Calculate area of squares
    2. Calculate area of rectangles
    3. Calculate area of triangles
    4. Calculate area of circles
    5. Quit

    2. If the user chooses to calculate the area of squares, an ‘area_of_squares’ method will ask for the following data which will be used to calculate and display the areas of the squares:

    First square side length (L)
    Number of further square areas to calculate (N)
    Square size increment (I)

    e.g. If the user enters L = 5, N = 3, I = 2 then three square areas of
    L = 5, L = 7 and L = 9 will be calculated and displayed.

    The formula for calculating the area of a square is:

    Area = L * L

    3. The other ‘areas’ types will be same except for the variables involved and the names of the methods:

    Area of Rectangles

    First rectangle length (L)
    First rectangle height (H)
    Number of further rectangle areas to calculate (N)
    Size increment (I)

    Formula is:

    Area = L * H

    Area of Triangles

    First triangle base length (L)
    First triangle height (H)
    Number of further triangle areas to calculate (N)
    Size increment (I)

    Formula is:

    Area = (L/2) * H

    Area of Circles

    First circle radius (R)
    Number of further circle area to calculate (N)
    Size increment (I)

    Formula is:

    Area = PI * R * R

    Where PI = 3.1415927

    4. If the user chooses to quit then they should be asked ‘if they are sure’ and if they are not, the program continues as previously described, otherwise the program terminates.


    Data Analysis

    Menu choices are Integers

    All area variables are floating point numbers

    User quit verification is a String
    I finished it off today, on the day it was supposed to be handed in . None of my friends knew that you had to have methods in the program, if it wasn't for me they would have all messed up the coursework.

  2. #2
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default Re: Java methods

    You seem to have done what was the assignment, even though i disagree with their general structure
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

  3. #3
    Time Lord Member The_Doctor's Avatar
    Join Date
    Oct 2004
    Location
    The TARDIS
    Posts
    2,040

    Default Re: Java methods

    You seem to have done what was the assignment, even though i disagree with their general structure
    I believe it was supposed to test our method making skills.

    How would you have structured the program?

  4. #4
    zombologist Senior Member doc_bean's Avatar
    Join Date
    Oct 2004
    Location
    Riding Shai-Hulud
    Posts
    5,346

    Default Re: Java methods

    Quote Originally Posted by The_Doctor
    I believe it was supposed to test our method making skills.

    How would you have structured the program?
    I would have separated the calculations from the inputs, I also don't see the point of the increments
    Yes, Iraq is peaceful. Go to sleep now. - Adrian II

  5. #5
    Time Lord Member The_Doctor's Avatar
    Join Date
    Oct 2004
    Location
    The TARDIS
    Posts
    2,040

    Default Re: Java methods

    I also don't see the point of the increments
    Neither do I.

    I believe it was supposed to test our for loop making skills.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO