Question

In: Computer Science

Write a program which alternately prints "Hello, world!" and "Buy Coca-Cola!" for fixed intervals, between screen...

Write a program which alternately prints "Hello, world!" and "Buy Coca-Cola!" for fixed intervals, between screen clears, indefinitely. The "Buy Coca-Cola" message should be below the liminal threshold (the user not be able to consciously perceive it), which is about 200ms. Call this blink.cpp. must be in c++

Solutions

Expert Solution

====================================================

====================================================

//Define all header files
#include <iostream>
#include <stdlib.h>
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif // win32

using namespace std;

//sleep function to sleep for specified number of milliseconds
void sleep(int milliseconds)
{

//Check for system of WIN32 bit
#ifdef WIN32
Sleep(milliseconds);   //Calling Sleep mehtod for specified milliseconds in WIN32 method
#else
usleep(milliseconds * 1000); //Calling usleep method for specified milliseconds in WIN32 method
#endif // win32
}

//main method
int main()
{
//Print Hello, world! on screen

cout<<"Hello, world!"<<endl;

//Sleepf ro 200 milliseconds
sleep(200);

//Print Buy Coca-Cola! on screen
cout<<"Buy Coca-Cola!"<<endl;

//Clear screen before it go for next execution
system("cls");

//Calling main method again for calling indefinitely
main();
}


Related Solutions

Define the micro-operations in the Coca-Cola World.
Define the micro-operations in the Coca-Cola World.
5. The Coca-Cola World service process is demand- or capacity-constrained? 6. How could Coca-Cola World improve...
5. The Coca-Cola World service process is demand- or capacity-constrained? 6. How could Coca-Cola World improve its service process? 7. What is the main source of variation for Coca-Cola World and how could this variation be reduced?
5. The Coca-Cola World service process is demand- or capacity-constrained? 6. How could Coca-Cola World improve...
5. The Coca-Cola World service process is demand- or capacity-constrained? 6. How could Coca-Cola World improve its service process? 7. What is the main source of variation for Coca-Cola World and how could this variation be reduced? please use the below case study to solve: The history of Coca-Cola started in 1886 when the interest of Dr. John S. Pemberton, an Atlanta pharmacist, led him to develop a distinctive flavored soft drink that could be sold at soda fountains. He...
Write a java program that prints to the screen a countdown 2,4,6,8, and then "Who do...
Write a java program that prints to the screen a countdown 2,4,6,8, and then "Who do we appreciate!" (hint use a for loop). Create a java program which prints out a random goodwill message i.e. (Have a great day!) please have at least 4 messages. Write a java program that will ask the user to enter a number and print out to the screen until the number -3 is entered. Write a JAVA program that calls a method that finds...
python Write a program that prints your name 100 times to the screen. Write a function...
python Write a program that prints your name 100 times to the screen. Write a function that takes a string s and an integer n as parameters and prints the string s a total of n times (once per line). Write a for loop that prints all the integers from 3141 to 5926, skipping every other one. Write a for loop that prints every 5th integer from 5926 down to 3141. Write a program (using a for loop) to print...
Is the Coca Cola Company a multinational enterprise? Which activity has the Coca Cola company conducted...
Is the Coca Cola Company a multinational enterprise? Which activity has the Coca Cola company conducted to support its transactions across national borders? Did it follow a step-wise internalization process in the past years?
Q: write the following according to Coca-Cola company: Stages of Supply Chain Management in Coca Cola...
Q: write the following according to Coca-Cola company: Stages of Supply Chain Management in Coca Cola company, decision phase of Supply Chain Management in Coca-Cola, Coca-Cola cyclic view pull and push, Coca-Cola achieving strategic fit demand uncertainty and implied demand uncertainty.
Where are coca cola concentrate manufactured in the world, and what are the reasons?
Where are coca cola concentrate manufactured in the world, and what are the reasons?
Explain Coca-cola diversification and strategic alliances through Build-Borrow-or-Buy Framework.
Explain Coca-cola diversification and strategic alliances through Build-Borrow-or-Buy Framework.
1. Explain Coca-cola diversification and strategic alliances through Build-Borrow-or-Buy Framework.
1. Explain Coca-cola diversification and strategic alliances through Build-Borrow-or-Buy Framework.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT