Write a simple way to write this code in C using cases Write a main function tha
ID: 3669905 • Letter: W
Question
Write a simple way to write this code in C using cases
Write a main function that prompts the user to enter a non-negative integer resistance value between 0 and 99x10 ^9, reads in the integer resistance in Ohms from the keyboard and passes it to a function color_band(). Since a valid resistance must be between 0 and 99x10 ^9, if the user enters a value outside that range, your program will print to the screen "You entered a resistance outside the range 0 to 99x109 Please re-enter a valid integer resistance value." and your program will then read-in the next integer from the keyboard. This will continue no matter how many times the user enters an invalid integer, until the user enters a valid integer resistance within the prescribed range The function color band) receives one parameter that holds the integer resistance entered by the user. The function color_band() determines the color code that represent the color code resistance that is closest to that entered by the user and prints that resistance value to the screen. Function color_band) then calls a function printcolor() three times to print the three colors to the screen. Function printcolor() receives one parameter, an integer from 0 to 9 and prints the corresponding color to the screen. Color Code Black rown Red Orange Yellow Green ue Violet 4 ra White If the integer codes of the bands are (in order) color1, color2, and color3, the resis- tance in ohms is resistance (10 * color! + color2 ) * 10c0103 Note: the resistance color code method uses a sequence of three colors that denote two significant digits times a power of 10. For example, if the user enters 264, the color code is Red Blue Brown for 260. If the user enters 266, the color code is Red Violet Brown for 270. Round for example 17500, up to the next significant digit, i.e. 18000. Perhaps the hardest part of this project is to round an arbitrary integer to two significant digits. There are a number of ways of correctly programming this. Determine how you are going to round an arbitrary integer to two significant digits before you start programming.Explanation / Answer
Hi below i written a example C Program that prompts the user to enter the non-negative integer and display the count, maximum, minimum and average. Terminate when user enters -1. This program helps you to understand and develop for your requirements and your function,
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.