// operating system Ubunut,Linux,Mac
// filename messageService.cpp
#include
#include // for vector
#include
using namespace std;
/*Main function start*/
int main()
{
std::vector > store;// we are using vector for storing pair of name and message
std::vector >::reverse_iterator it;// used to reverse iteration
std::string name,message,input,choice;// variable for purpose
do{
std::cout<<\"Enter User Name> \";
std::cin>>name;
std::cout<<\"Enter Message> \";// prompt for user input
/* we are taking input from user as string
* if line contains $$ then it will break and come out from loop
* otherwise it will create pair and insert it into vector*/
while(std::getline(std::cin,input)){
if(input==\"$$\")
break;
message+=input+\"\ \";
}
store.push_back(std::pair(name,message));// inserting pair into vector
message=\"\";
std::cout<<\"Any More Users? > \";
std::cin>>choice;
}while(choice==\"yes\");
/*while loop break if choice value other then \"yes\" */
std::cout << \"The current messages are: \ \";
/*Iterating vector in reverse order for printing desirable output*/
for (it=store.rbegin(); it!=store.rend(); ++it){
std::cout << it->first << \" >> \"<second << \'\ \';
}
return 0;
}
/*Main function End*/
/*Output*/
gopal@gopal:~/Desktop/chegg$ g++ messageService.cpp
gopal@gopal:~/Desktop/chegg$ ./a.out
Enter User Name> Kate
Enter Message> Get in the loop and join our War Eagle group!
Sunner in st. John\'s islands was fun.
How was your summer?
$$
Any More Users? > yes
Enter User Name> Daniel
Enter Message> I\'m in!
$$
Any More Users? > yes
Enter User Name> Joey
Enter Message> Count me in.
We were in Tokyo; intersting!
$$
Any More Users? > yes
Enter User Name> Kevin
Enter Message> What\'s new?
we had a great time in the Outback.
$$
Any More Users? > no
The current messages are:
Kevin >>
What\'s new?
we had a great time in the Outback.
Joey >>
Count me in.
We were in Tokyo; intersting!
Daniel >>
I\'m in!
Kate >>
Get in the loop and join our War Eagle group!
Sunner in st. John\'s islands was fun.
How was your summer?
Solution
// operating system Ubunut,Linux,Mac
// filename messageService.cpp
#include
#include // for vector
#include
using namespace std;
/*Main function start*/
int main()
{
std::vector > store;// we are using vector for storing pair of name and message
std::vector >::reverse_iterator it;// used to reverse iteration
std::string name,message,input,choice;// variable for purpose
do{
std::cout<<\"Enter User Name> \";
std::cin>>name;
std::cout<<\"Enter Message> \";// prompt for user input
/* we are taking input from user as string
* if line contains $$ then it will break and come out from loop
* otherwise it will create pair and insert it into vector*/
while(std::getline(std::cin,input)){
if(input==\"$$\")
break;
message+=input+\"\ \";
}
store.push_back(std::pair(name,message));// inserting pair into vector
message=\"\";
std::cout<<\"Any More Users? > \";
std::cin>>choice;
}while(choice==\"yes\");
/*while loop break if choice value other then \"yes\.
Salient Features of India constitution especially power and functions
operating system Ubunut,Linux,Mac filename messageService.cpp.pdf
1. // operating system Ubunut,Linux,Mac
// filename messageService.cpp
#include
#include // for vector
#include
using namespace std;
/*Main function start*/
int main()
{
std::vector > store;// we are using vector for storing pair of name and message
std::vector >::reverse_iterator it;// used to reverse iteration
std::string name,message,input,choice;// variable for purpose
do{
std::cout<<"Enter User Name> ";
std::cin>>name;
std::cout<<"Enter Message> ";// prompt for user input
/* we are taking input from user as string
* if line contains $$ then it will break and come out from loop
* otherwise it will create pair and insert it into vector*/
while(std::getline(std::cin,input)){
if(input=="$$")
break;
message+=input+" ";
}
store.push_back(std::pair(name,message));// inserting pair into vector
message="";
std::cout<<"Any More Users? > ";
std::cin>>choice;
}while(choice=="yes");
/*while loop break if choice value other then "yes" */
std::cout << "The current messages are: ";
/*Iterating vector in reverse order for printing desirable output*/
for (it=store.rbegin(); it!=store.rend(); ++it){
std::cout << it->first << " >> "<second << ' ';
2. }
return 0;
}
/*Main function End*/
/*Output*/
gopal@gopal:~/Desktop/chegg$ g++ messageService.cpp
gopal@gopal:~/Desktop/chegg$ ./a.out
Enter User Name> Kate
Enter Message> Get in the loop and join our War Eagle group!
Sunner in st. John's islands was fun.
How was your summer?
$$
Any More Users? > yes
Enter User Name> Daniel
Enter Message> I'm in!
$$
Any More Users? > yes
Enter User Name> Joey
Enter Message> Count me in.
We were in Tokyo; intersting!
$$
Any More Users? > yes
Enter User Name> Kevin
Enter Message> What's new?
we had a great time in the Outback.
$$
Any More Users? > no
The current messages are:
Kevin >>
What's new?
we had a great time in the Outback.
Joey >>
Count me in.
We were in Tokyo; intersting!
Daniel >>
3. I'm in!
Kate >>
Get in the loop and join our War Eagle group!
Sunner in st. John's islands was fun.
How was your summer?
Solution
// operating system Ubunut,Linux,Mac
// filename messageService.cpp
#include
#include // for vector
#include
using namespace std;
/*Main function start*/
int main()
{
std::vector > store;// we are using vector for storing pair of name and message
std::vector >::reverse_iterator it;// used to reverse iteration
std::string name,message,input,choice;// variable for purpose
do{
std::cout<<"Enter User Name> ";
std::cin>>name;
std::cout<<"Enter Message> ";// prompt for user input
/* we are taking input from user as string
* if line contains $$ then it will break and come out from loop
* otherwise it will create pair and insert it into vector*/
while(std::getline(std::cin,input)){
if(input=="$$")
break;
message+=input+" ";
}
store.push_back(std::pair(name,message));// inserting pair into vector
message="";
std::cout<<"Any More Users? > ";
std::cin>>choice;
4. }while(choice=="yes");
/*while loop break if choice value other then "yes" */
std::cout << "The current messages are: ";
/*Iterating vector in reverse order for printing desirable output*/
for (it=store.rbegin(); it!=store.rend(); ++it){
std::cout << it->first << " >> "<second << ' ';
}
return 0;
}
/*Main function End*/
/*Output*/
gopal@gopal:~/Desktop/chegg$ g++ messageService.cpp
gopal@gopal:~/Desktop/chegg$ ./a.out
Enter User Name> Kate
Enter Message> Get in the loop and join our War Eagle group!
Sunner in st. John's islands was fun.
How was your summer?
$$
Any More Users? > yes
Enter User Name> Daniel
Enter Message> I'm in!
$$
Any More Users? > yes
Enter User Name> Joey
Enter Message> Count me in.
We were in Tokyo; intersting!
$$
Any More Users? > yes
Enter User Name> Kevin
Enter Message> What's new?
we had a great time in the Outback.
$$
Any More Users? > no
The current messages are:
5. Kevin >>
What's new?
we had a great time in the Outback.
Joey >>
Count me in.
We were in Tokyo; intersting!
Daniel >>
I'm in!
Kate >>
Get in the loop and join our War Eagle group!
Sunner in st. John's islands was fun.
How was your summer?