AQA Computer Science AS - HELP ON PSEUDOCODE (VB)

Watch
1017bsquad
Badges: 2
Rep:
?
#1
Report Thread starter 6 years ago
#1
Guys I really require assistance on pseudocode I simply cannot write this piece of pseudocode into visual basics. This is the code: http://prntscr.com/7ajkpf
May someone perhaps explain and rewrite this piece of pseudocode into visual basics? Things such as when it goes "ENDFOR" how to do this?
0
reply
jhjamie
Badges: 3
Rep:
?
#2
Report 6 years ago
#2
(Original post by 1017bsquad)
Guys I really require assistance on pseudocode I simply cannot write this piece of pseudocode into visual basics. This is the code: http://prntscr.com/7ajkpf
May someone perhaps explain and rewrite this piece of pseudocode into visual basics? Things such as when it goes "ENDFOR" how to do this?
Hope this helps. ENDFOR is simply translated to the VB code you would to end a for loop; next. (e.g. if it said ENDDO then we would put Loop)

Anymore questions, feel free to PM me.

Dim N As Integer
Dim Binary(8) As String
Dim BinaryPoint As Integer
Dim Count As Integer
Dim Bit As Integer
Dim Column As Single
Dim whole As Integer
Dim fraction As Single
Dim Denary As Single
N = 8
For count = 1 To N
Console.WriteLine("Enter bit")
Binary(Count) = Console.ReadLine
Next

Console.WriteLine("Enter position of binary point"
BinaryPoint = Console.ReadLine()

Column = 1
whole = 0

For Bit = BinaryPoint To 1 Step -1
whole = whole + (Binary(Bit) * Column)
Column = Column * 2
Next

Column = 0.5
Fraction = 0

For Bit = BinaryPoint To N
fraction = fraction + (Binary(Bit) * Column)
Column = Column / 2
Next
Denary = (whole + fraction)
Console.WriteLine("In Decimal:" & Denary)
0
reply
Async
Badges: 19
Rep:
?
#3
Report 6 years ago
#3
^^ Use code tags . Other than that, nice work.
0
reply
1017bsquad
Badges: 2
Rep:
?
#4
Report Thread starter 6 years ago
#4
(Original post by jhjamie)
Hope this helps. ENDFOR is simply translated to the VB code you would to end a for loop; next. (e.g. if it said ENDDO then we would put Loop)

Anymore questions, feel free to PM me.

Dim N As Integer
Dim Binary(8) As String
Dim BinaryPoint As Integer
Dim Count As Integer
Dim Bit As Integer
Dim Column As Single
Dim whole As Integer
Dim fraction As Single
Dim Denary As Single
N = 8
For count = 1 To N
Console.WriteLine("Enter bit"
Binary(Count) = Console.ReadLine
Next

Console.WriteLine("Enter position of binary point"
BinaryPoint = Console.ReadLine()

Column = 1
whole = 0

For Bit = BinaryPoint To 1 Step -1
whole = whole + (Binary(Bit) * Column)
Column = Column * 2
Next

Column = 0.5
Fraction = 0

For Bit = BinaryPoint To N
fraction = fraction + (Binary(Bit) * Column)
Column = Column / 2
Next
Denary = (whole + fraction)
Console.WriteLine("In Decimal:" & Denary)
omfg thank you so much man and yah i will definitely pm if i need more help !
0
reply
1017bsquad
Badges: 2
Rep:
?
#5
Report Thread starter 6 years ago
#5
(Original post by Async)
^^ Use code tags . Other than that, nice work.
In the pseudo code it says DO LOOP, why is it that in the translated VB code there isn't a do loop?
0
reply
jhjamie
Badges: 3
Rep:
?
#6
Report 6 years ago
#6
(Original post by 1017bsquad)
In the pseudo code it says DO LOOP, why is it that in the translated VB code there isn't a do loop?
There is
---------------
Do

Loop
--------------

That is a do loop in VB. However, that is not what the pseudo means. It is simply stating perform the for loop.
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Should the school day be extended to help students catch up?

Yes (76)
29.69%
No (180)
70.31%

Watched Threads

View All