Great Deal! Get Instant \$10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

# One common way for software specifications such as HTML to specify colors is with a hexadecimal string. For instance the color aquamarine is represented by the string "#7FFFD4" . Here's how the string...

One common way for software specifications such as HTML to specify colors is with a hexadecimal string. For instance the color aquamarine is represented by the string`"#7FFFD4"`. Here's how the string breaks down:

• The first character is always`"#"`.
• The second and third character are the red channel value, represented as a hexadecimal value between`00`and`FF`. In this example, the red channel value is 127, which in hexadecimal is`7F`.
• The fourth and fifth character are the green channel value, represented the same way. In this example, the green channel value is 255, which in hexadecimal is`FF`.
• The sixth and seventh character are the blue channel value, represented the same way. In this example, the blue channel value is 212, which in hexadecimal is`D4`.

All three channel values must be an integer between 0 (minimum brightness) and 255 (maximum brightness). In all cases the hex values are two digits each, including a leading`0`if necessary.See the Wikipedia page for more examples, and a link for how to convert a number to hexadecimal.

Assignment

Given three integers between 0 and 255, corresponding to the red, green, and blue channel values of a color, find the hex string for that color. You may use anything built into your programming language, such as for base conversion, but you can also do it manually.

Example

``R: 255G: 99B: 71 HEX: #FF6347 ``
Hint

You can use built in C# functionality to achieve this. If you declare the 0-255 value as a byte, you can then useToString()on it, in conjunction with specialformat stringinside the parenthesis (look for "X" format string in the table on the linked page).

Extra Credit

Given two hex color strings, produce the hex color string you get from averaging their RGB values together. You'll need to round channel values to integers.

``HEX Color 1: #000000HEX Color 2: #778899HEX Blended: #3C444C``

This is not actually the best way to blend two hex colors: to do it properly you need gamma correction. But that's another story.

Answered Same Day Aug 21, 2021

## Solution

Neha answered on Aug 23 2021
using System;
class Converto
{
static string decToHexa (int n)
{
int i = 0;
while (n != 0)
{
int temp = 0;
temp = n % 16;
if (temp < 10)
{
hexaDeciNum[i] = (char) (temp + 48);
i++;
}
else
{
hexaDeciNum[i] = (char) (temp + 55);
i++;
}
n = n / 16;
}
string hexCode = "";
if (i == 2)
{
}
else if (i == 1)
{
hexCode = "0";
}
else if (i == 0)
hexCode =...
SOLUTION.PDF