90 314
Assignments Done
99.3%
Successfully Done
In September 2020

# Answer to Question #20541 in Visual Basic for lekan

Question #20541
Design a program that would allow a user to enter a resistor value in ohms and then provide the resistor colour code for the given value.
1
2012-12-12T08:24:57-0500
Module Module1

Sub Main()
Dim colors() As String = {&quot;BLACK&quot;, &quot;BROWN&quot;,
&quot;RED&quot;, &quot;ORANGE&quot;, &quot;YELLOW&quot;, &quot;GREEN&quot;,
&quot;BLUE&quot;, &quot;PURPLE&quot;, &quot;GRAY&quot;, &quot;WHITE&quot;}

Dim resistorvalue As Integer
Console.Write(&quot;Enter a resistor value: &quot;)
If resistorvalue.ToString().Length = 1 Then
Console.Write(colors(Integer.Parse(resistorvalue.ToString()(0))) + &quot;
&quot; + colors(0) + &quot; &quot; + colors(0))
End If
If resistorvalue.ToString().Length = 2 Then
Console.Write(colors(Integer.Parse(resistorvalue.ToString()(0))) + &quot;
&quot; + colors(Integer.Parse(resistorvalue.ToString()(1))) + &quot; &quot; +
colors(0))
End If

If resistorvalue.ToString().Length = 3 Then
Console.Write(colors(Integer.Parse(resistorvalue.ToString()(0))) + &quot;
&quot; + colors(Integer.Parse(resistorvalue.ToString()(1))) + &quot; &quot; +
colors(Integer.Parse(resistorvalue.ToString()(2))))
End If

End Sub

End Module

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!