Results 1 to 3 of 3
  1. #1
    renzzy is offline Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Default Truncate and If statement with "is not a whole number"

    Our prof. gave us this pseudocode...he wants us to research and transform it into an actual program...

    i'm having a big problem on this part of the pseudocode

    if(Interval is not a whole number) then
    {
    truncate interval
    }

    how can i use a if statement in determining if it is a decimal or a whole number??

    and how do i use truncate??
    truncating it into ones twos or threes...

    this code has an array of 14 names i didn't include them


    Pseudocode
    Shell_Sort(Arr,N)
    {
    If(N=1) then
    {
    Exit
    }
    Set Interval to N
    while(Interval is not 1)
    {
    Set Interval to ((Interval/3)+1)
    If(Interval is not a whole number) then
    {
    Truncate Interval
    }

    Set start to 1
    while(start <= Interval)
    {
    Sort()
    Increment start
    }
    }
    }

    sort()
    {
    set Unsrt_Indx to (start + interval)

    while(unsrt_Indx <= N)
    {
    if (Arr[Unsrt_Indx - Interval] > arr[unsrt_Indx] then
    {
    set str_indx to unsrt_indx
    set temp to arr[srt_indx]

    while((str_indx >start && (arr[str_indx-Interval] > temp))
    {
    set arr[set_indx] to arr[str_index- interval]
    set str_indx to (crt_index - interval)
    }

    set arr[str_indx] to temp
    }

    set unsrt_indx to (unsrt_indx + interval)
    }
    }


    please help!! :)

    i possible help me transform this into a program :)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

    Default Re: Truncate and If statement with "is not a whole number"

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default Re: Truncate and If statement with "is not a whole number"

    Experiment with some of the Math class's methods using println to print out the results to see if any of them will do what you want.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 0
    Last Post: 12-07-2012, 08:29 AM
  2. Replies: 3
    Last Post: 10-30-2012, 03:06 PM
  3. An "if" statement inside a "for" loop?
    By soccermiles in forum New To Java
    Replies: 18
    Last Post: 04-20-2010, 03:44 AM
  4. Replies: 3
    Last Post: 05-25-2009, 08:50 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 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
  •