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
Expert's answer
2012-12-12T08:24:57-0500
Module Module1
Sub Main() Dim colors() As String = {"BLACK", "BROWN", "RED", "ORANGE", "YELLOW", "GREEN", "BLUE", "PURPLE", "GRAY", "WHITE"}
Dim resistorvalue As Integer Console.Write("Enter a resistor value: ") resistorvalue = Integer.Parse(Console.ReadLine()) If resistorvalue.ToString().Length = 1 Then Console.Write(colors(Integer.Parse(resistorvalue.ToString()(0))) + " " + colors(0) + " " + colors(0)) End If If resistorvalue.ToString().Length = 2 Then Console.Write(colors(Integer.Parse(resistorvalue.ToString()(0))) + " " + colors(Integer.Parse(resistorvalue.ToString()(1))) + " " + colors(0)) End If
If resistorvalue.ToString().Length = 3 Then Console.Write(colors(Integer.Parse(resistorvalue.ToString()(0))) + " " + colors(Integer.Parse(resistorvalue.ToString()(1))) + " " + colors(Integer.Parse(resistorvalue.ToString()(2)))) End If Console.ReadLine()
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment