Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Denary numbers to binary for numbers below 255
'Rextester.Program.Main is the entry point for your code. Don't change it. 'Compiler version 11.0.50709.17929 for Microsoft (R) .NET Framework 4.5 Imports System Imports System.Collections.Generic Imports System.Linq Imports System.Text.RegularExpressions Namespace Rextester Public Module Program Dim count As Integer Dim constants(8) As Integer Dim values(8) As Integer Dim value As Integer Dim value1 As Integer Dim answers(8) As Integer Dim number As Integer Public Sub Main(args() As string) 'Your code goes here Console.WriteLine("Denary to binary converter") Console.WriteLine("Please enter a denary number") Console.WriteLine("It will also include step-by-step instructions") Console.WriteLine("Please make sure that you enter a number below 255") number=Console.ReadLine() If number>255 Then Do Console.WriteLine("The number you entered is invalid") Console.WriteLine("Please enter a number below 255") number=Console.ReadLine() Loop Until number<=255 End If value=number count=0 constants(8)=128 constants(7)=64 constants(6)=32 constants(5)=16 constants(4)=8 constants(3)=4 constants(2)=2 constants(1)=1 Console.WriteLine("-------------------------") Console.WriteLine("Current value is " & value) For count=0 To 7 Console.WriteLine("Using value of " & value) Console.WriteLine("Count value has been incremented") Console.WriteLine("Current count value is " & count) Console.WriteLine("Subtracting " & constants(8-count)) values(count)=value-constants(8-count) If values(count)<0 Then Console.WriteLine("Error: The value is less than zero") Do Console.WriteLine("Subtracting a lower value to fix the error") count=count+1 Console.WriteLine("Count value has been incremented") Console.WriteLine("Current count value is " & count) Console.WriteLine("Subtracting " & constants(8-count)) values(count)=value-constants(8-count) Console.WriteLine("Current value is " & values(count)) Loop Until values(count)>=0 Console.WriteLine("Error fixed") End If answers(count)=1 value=values(count) Next Console.WriteLine("----------------------") Console.WriteLine("Number " & number & " is " & answers(0) & answers(1) & answers(2) & answers(3) & answers(4) & answers(5) & answers(6) & answers(7) & " in binary") Console.ReadLine() End Sub End Module End Namespace
run
|
edit
|
history
|
help
0
Andrew Williams
Exercício de variáveis 1
exercicio 2 2019 11 11
Reed Solomon error correction (failure)
Selected Poems of Rumi Dover Thrift Edition...day#doy~Poem#n
No Fear Shakespeare sonnet of the day
ok
wunder
CD.SYS
DateTime.ParseExact