# Thread: Truncate and If statement with "is not a whole number"

1. Member
Join Date
Mar 2013
Posts
1
Rep Power
0

## 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)
}
}

i possible help me transform this into a program :)

3. ## 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.

#### Posting Permissions

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