Write a function rgb(r, g, b) which returns the HTML color string for those red, green and blue values. The valid arguments are 0-255. If any argument is outside of that range, then throw a domain_error exception, indicating the values that are passed in. In formatting the returned value, you may find the hex and uppercase output manipulators useful. #include #include #include #include using namespace std; /** Returns the html color code, given red, green and blue values @param red - between 0-255 inclusive @param green - between 0-255 inclusive @param blue - between 0-255 inclusive @return an HTML color string (#FFDCBD) */ string rgb(int red, int green, int blue) { ... }
Write a function rgb(r, g, b) which returns the HTML color string for those red, green and blue values. The valid arguments are 0-255. If any argument is outside of that range, then throw a domain_error exception, indicating the values that are passed in. In formatting the returned value, you may find the hex and uppercase output manipulators useful.
#include <string>
#include <sstream>
#include <iomanip>
#include <stdexcept>
using namespace std;
/**
Returns the html color code, given red, green and blue values
@param red - between 0-255 inclusive
@param green - between 0-255 inclusive
@param blue - between 0-255 inclusive
@return an HTML color string (#FFDCBD)
*/
string rgb(int red, int green, int blue)
{
...
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images