The colored bands on the top-most resistor shown in the photo below indicate a resistance of 6.2
Question:
The colored bands on the top-most resistor shown in the photo below indicate a resistance of 6.2 kΩ ±5 percent. The resistor tolerance of ±5 percent indicates the acceptable variation in the resistance. A 6.2 kΩ ±5 percent resistor could have a resistance as small as 5.89 kΩ or as large as 6.51 kΩ. We say that 6.2 kΩ is the nominal value of the resistance and that the actual value of the resistance can be any value between 5.89 kΩ and 6.51 kΩ.
Write a program that represents a resistor as a class. Provide a single constructor that accepts values for the nominal resistance and tolerance and then determines the actual value randomly. The class should provide public methods to get the nominal resistance, tolerance, and the actual resistance. Write a main method for the program that demonstrates that the class works properly by displaying actual resistances for ten 330 Ω ±10 percent resistors.
Step by Step Answer: