Question

In: Computer Science

3.24 LAB C++ : Program: Text message decoder (1) Use getline() to get a line of...

3.24 LAB C++ : Program: Text message decoder

(1) Use getline() to get a line of user input into a string. Output the line. (3 pts)

Ex:

Enter text:
IDK if I'll go. It's my BFF's birthday. 
You entered: IDK if I'll go. It's my BFF's birthday.


(2) Search the string (using find()) for common abbreviations and print a list of each found abbreviation along with its decoded meaning. (3 pts)

Ex:

Enter text:
IDK if I'll go. It's my BFF's birthday. 
You entered: IDK if I'll go. It's my BFF's birthday. 
BFF: best friend forever
IDK: I don't know

Support these abbreviations:

  • BFF -- best friend forever
  • IDK -- I don't know
  • JK -- just kidding
  • TMI -- too much information
  • TTYL -- talk to you later

pls help this is so confusing!!

Solutions

Expert Solution

Please find your solution below and if any doubt or need change comment.And do upvote.

CODE:

#include <iostream>
#include<string>
using namespace std;

int main()
{
    string str;
    int index;
    //take input using getline
    cout<<"Enter text:"<<endl;
    getline(cin,str,'\n');
    cout<<"You entered: "<<str<<endl;
    
    //using find() function find if these  string 
    //are present or not 
    index = str.find( "BFF", 0 );
    if( index != string::npos )
    {
       cout<<"BFF: best friend forever\n";
    }
    index = str.find( "IDK", 0 );
    if( index != string::npos )
    {
       cout<<"IDK: I don\'t know\n";
    }
    index = str.find( "JK", 0 );
    if( index != string::npos )
    {
       cout<<"JK: just kidding\n";
    }
    index = str.find( "TMI", 0 );
    if( index != string::npos )
    {
       cout<<"TMI: too much information\n";
    }
    index = str.find( "TTYL", 0 );
    if( index != string::npos )
    {
       cout<<"TTYL: talk to you later\n";
    }

    return 0;
}

OUTPUT:


Related Solutions

A Java program that deciphers each message by building the string. Each line of the text...
A Java program that deciphers each message by building the string. Each line of the text file contains either a word or a command followed by a forward slash and the requirements of the command. A Stack Implementation is needed as. As you read the data from the text file, you need to know if it is a new phrase or command. The commands are: i – an insert followed by the letters, numbers, or symbols that need to be...
Create a message encoder/decoder. PLEASE USE BASIC PYTHON METHODS/FUNCTIONS. The user enters a message that could...
Create a message encoder/decoder. PLEASE USE BASIC PYTHON METHODS/FUNCTIONS. The user enters a message that could only include alphabetic letters and space. There are 26 alphabetic letters. Consider space the 27th letter. The user then enters a shift code that should be an integer between -26 and 26. The application will show the encoded/decoded message based on the shift code entered. If you encode a message, each letter in the message will be moved forward through the alphabet according to...
Whenever I am attempting to write a simple program on C++ I get an error message...
Whenever I am attempting to write a simple program on C++ I get an error message that reads "cout was not declared in this scope". Literally every time. This has become frustrating because I have even written my code the exact same way as some of my classmates who got theirs to compile and run with no sign of this error at all, and yet min gives this answer. I will leave an example of a code where this error...
Write a c or matlab text code(to be copied ) for Huffman coder and Huffman decoder...
Write a c or matlab text code(to be copied ) for Huffman coder and Huffman decoder that asks the user to enter the string and output the Huffman code for every letter and a code for encoding that will have every letter and its Huffman code and output all the possibilities for the real string. you must show a screen of an input and the output for both the encoder and the decoder
C++ Write a program that reads a line of text, changes each uppercase letter to lowercase,...
C++ Write a program that reads a line of text, changes each uppercase letter to lowercase, and places each letter both in a queue and onto a stack. The program should then verify whether the line of text is a palindrome (a set of letters or numbers that is the same whether read forward or backward). Please use a Queue Class and Stack class.
Write a program that takes in a line of text as input, and outputs that line...
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text. Ex: If the input is: Hello there Hey quit then the output is: ereht olleH yeH IN C++ PLEASE!
The purpose of this lab:  Wireshark Intro Lab is to get students familiar with the use of...
The purpose of this lab:  Wireshark Intro Lab is to get students familiar with the use of their VMs and running wireshark on their VMs. We also examine Ethernet, IPv4, and TCP addressing at the Network Access, Network, and Transport layers of the TCP/IP stack. Reflection: In two paragraphs reflect the experience of using Wireshark capture (in the lab) on the following questions: What was the most valuable feature of the lab? How did you prepare for this lab? What changes...
I am doing a lab and I get this error message in my unittest: junit.framework.AssertionFailedError: Hint:...
I am doing a lab and I get this error message in my unittest: junit.framework.AssertionFailedError: Hint: matches() should have returned true when item matches the item passed into IdLookup constructor. Here is my code. What changes should be made? /** * This class is a lookup that matches items whose id matches exactly * a specified id, to be passed into the constructor when creating * the instance of the lookup. * * @author Franklin University * @version 2.0 */...
implement a Message Authentication Code program in either C/C++ or Python. See the following steps. 1....
implement a Message Authentication Code program in either C/C++ or Python. See the following steps. 1. Accept a message as keyboard input to your program. 2. Accept a secret key for the sender/recipient as keyboard input to your program. 3. Your hash function H() is simply the checksum. To compute the checksum, you add all the characters of the string in ASCII codes. For example, the checksum of a string "TAMUC" would be 84 + 65 + 77 + 85...
**Use C** You will write an encoder and a decoder for a modified "book cipher." A...
**Use C** You will write an encoder and a decoder for a modified "book cipher." A book cipher uses a document or book as the cipher key, and the cipher itself uses numbers that reference the words within the text. For example, one of the Beale ciphers used an edition of The Declaration of Independence as the cipher key. The cipher you will write will use a pair of numbers corresponding to each letter in the text. The first number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT