I am to write a While loop, and Do - While loop and a FOR loop that all do this exact thing. I have my While and DO-While algorithms written but am having some difficulty converting the program to a FOR loop, and suggestions to help get me started in the right direction would be greatly appreciated.

While Loop:

Set count=0 //initialize counter and variables set MaxValue=6 Set TotalEven=0 Set TotalOdd=0 While count < Max Value Input Num SignDet=NumMod2 //operation to determine if number entered is odd or even if SignDet=0 TotalEven=TotalEven + 1 Else TotalOdd=TotalOdd + 1 End If count=count+1 //increment counter End While Display "You entered six numbers: " & TotalOdd & " odd numbers and" & TotalEven & " even numbers." //display number of even and odd numbers were entered Do While Loop: Set count=0 //initialize counter and variables set MaxValue=6 Set TotalEven=0 Set TotalOdd=0 Do Input Num SignDet=NumMod2 //operation to determine if number is even or odd if SignDet = 0 TotalEven=TotalEven + 1 Else TotalOdd=TotalOdd + 1 End If count = count + 1 While count < MaxValue End While Display "You entered six numbers: " & TotalOdd & " odd numbers and" & TotalEven & " even numbers."

I know that the FOR loop is made specifically to initialize, test and increment a counter variable and I have the format of the pseudocode but for some reason am struggling with putting the program into a For loop.

My attempt is:

Set counter = 1 //initialize counter and variables Set MaxValue = 6 Set TotalEven = 0 Set TotalOdd = 0 For counter = 1 to MaxValue Input Num SignDet = NumMod2 If SignDet = 0 TotalEven=TotalEven + 1 Else TotalOdd = TotalOdd +1 End If count=count +1 End For Display "You entered six numbers: " & TotalOdd & " odd numbers and" & TotalEven & " even numbers."

I am not sure if this is correct or not. I am a math major and only taking intro to computer program as a requirement of my major. I find myself having a tough time wrapping my mind around the logic used to program so any help anyone could give me would be greatly appreciated. Thanks so much for taking the time to help me and sorry if I posted incorrectly.

MOD EDIT: When posting code...USE CODE TAGS!!!

This post has been edited by **JackOfAllTrades**: 18 April 2011 - 06:36 AM