Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to print white lowercase \'o\'s on a black background across

ID: 3783350 • Letter: W

Question

Write a C++ program to print white lowercase 'o's on a black background across the middle of the screen.

Next, have a captial 'O' move from left to right, and back, on top of the lower-case 'o's using each of the colors specified by the ANSI escape sequences.

After you've "bounced" a white 'O', go to the next line and end your program.

You may assume a screen size of 80x25 (80 chars across by 25 lines)

Basic animation is a simple 3-step process:

Draw something

Pause so the eye can see it

Erase the old and go to #1

To do this, you'll need a pause function. Since we have not discussed this you'll need to use the following code in your program:

Here is an example:

The 0 moves from left to right and changes color every time it gets back to the leftmost o.

00000000000000000000 0000000000000

Explanation / Answer

inline void SetColor(WORD color){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); } // helper class class color { public: color(WORD val) : m_val(val) { } void set() const { SetColor(m_val); } private: WORD m_val; }; // instances of helper class to avoid need to remember 4 is red, etc static const color red(4); static const color green(2); static const color blue(1); static const color white(7); // etc // overload operator
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote