From ce2805d40395f306cc327992635ac918185deda9 Mon Sep 17 00:00:00 2001 From: Kevin Buffardi Date: Mon, 18 Sep 2023 17:14:33 -0700 Subject: [PATCH] Repeats for wrong length input --- main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..720581b --- /dev/null +++ b/main.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; +const int RGB_HEX_LENGTH = 7; + +int main(){ + string input; + + do{ + cout << "Enter a color in hex format (#RRGGBB):"; + getline(cin, input); + + if( input.size() != RGB_HEX_LENGTH ){ + cout << "Please enter the color in hexadecimal format, starting with # followed by six hex values\n"; + } + }while( input.size() != RGB_HEX_LENGTH ); + + cout << "Your hex color is: " << input << endl; + + return 0; +} \ No newline at end of file