From 6dcc5b9a90005df578a2b27dee98618db271dd0a Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sun, 3 Feb 2019 11:57:14 -0600 Subject: Finish problem --- ee1301/wk1/hw1_directory/strap012_1B.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'ee1301/wk1') diff --git a/ee1301/wk1/hw1_directory/strap012_1B.cpp b/ee1301/wk1/hw1_directory/strap012_1B.cpp index 02fd560..f5a00da 100644 --- a/ee1301/wk1/hw1_directory/strap012_1B.cpp +++ b/ee1301/wk1/hw1_directory/strap012_1B.cpp @@ -1,5 +1,6 @@ #include #include +#include using namespace std; int main() @@ -9,17 +10,23 @@ int main() cin >> option; if (option == "i") { - - cout << "E"; - + int r; + int g; + int b; + cout << "Input r, g, b: "; + cin >> r >> g >> b; + cout << fixed << setprecision(2) << "Float representation: " << r / 255.0 << ", " << g / 255.0 << ", " << b / 255.0; }else{ if (option == "f") { - - cout << "e"; - + double r; + double g; + double b; + cout << "Input r, g, b: "; + cin >> r >> g >> b; + cout << fixed << setprecision(0) << "Integer representation: " << r * 255 << ", " << g * 255 << ", " << b * 255; }else{ - - cout << "Invalid option."; + cout << "Invalid option." << endl; + return 0; } } - cout << endl; + cout << endl; } \ No newline at end of file -- cgit v1.2.3