Can Anyone help?

Hello,
I am currently taking a computer science class, I have run into something i just can't figure out. This is what is asked of me in this assessment"For this assignment you will create a simple text converter. The idea
is to convert normal text into "messaging" text or vice versa. For
example, "see you later" would be converted to "c u l8r" and "lol"
would be converted to "laugh out loud". If anyone could help that would be Awesome!!
Well you could write up a simple peice of code that uses std::string for the message, and it searches for "see you later" and set it to replace "c u l8r". Also, welcome to the forum.
Last edited on
Depends on how many text strings there are and how often you would want to add to the list.

If your going to update it, have it check a file for the string and matching output.

If its' just a few examples then you could put it in an array, or just simple if statements

if (String = "see you")
{cout << "c u "};
else if (String = "later")
{cout << "l8r "};
....

Make sure to allow for spaces.
You can also use map (STL) to store this data and program your code like if the conversion is present it will display it otherwise it will be added in map.

This seems interesting you can take different approaches like the ones mentioned you can also use two arrays having one array take in the words that are like "laugh out loud" and "see you later" and the other array is the messaging text.
Have the user enter the text and have function that checks one array and if not there check the other array. Have it return the position of the array and use it to print the other arrays at that position.

ex:
regular[10] = "see you later";
message[10] = "c u l8r"

You can also have a .upper() when checking just in case they type it in different cases.

Many approaches to a single problem.
The first thing that popped in my head was to define a matrix with correlating phrases.
While you can parse strings it may be more simple to use complete strings
after adjusting for capitalization

A0 "see you later" B0 "c u l8r"
A1 "laugh out loud" B1 "lol"

and so on. just look for a match and go from there
When you talk about a text converter, is it a function that "translates" a phrase at a time, or will you feed it a whole message (text/e-mail/...) and have it convert the entire text. As that will require not only the mapping ("lol" -> "laugh out loud", "c u" -> "see you", etc) in a map, arrays, array of stucts, etc but a way of walking though the next so you don't waste time searching all the way though the text for each string.

Andy
Thank you to all. i have tried to put this together, i don't know. any ideas? thanks for the help all..
//
// main.cpp
// chapter 8
//
// Created by Bradley Davis
// Copyright (c) 2015 Bradley Davis. All rights reserved.
//

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

int translate();
void displaywords();

//main function
int main ();


int translate;

english= sms();

while(translate !=3){
english= sms();
}
return 0;
}





//translate
int translate(){
int choice;
std::cout << "translate english to sms" <<std::endl;
std::cout << "translate sms to english" <<std::endl;
std::cout << "3-end" <<std::endl;

std::cin>> choice;
return choice;
}
//display words functon

void displaywords(){
ifstream objectfile(english.rft);
string sms;
double english;

if( sms){
while(objectfile >>sms >>english){
if(english){
cout << english << '' << sms <<endl;

}
}
}
}
Topic archived. No new replies allowed.