473,383 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

c++ alphabeth decoding

Good day. My semester of c++ is coming to an end. I've got to complete a total of 7 assignments within the next 3 weeks. I've completed 5 out of the seven. I've got two left (1 has a separate thread by itself). So you can also take a look at it. This is the assignment:

C++ Program - CODE TRANSLATOR
You have been hired you to write a special code translating program. They usually use a simple letter transformation, where the alphabets sequence of letters is started at somewhere other than the letter "A".
Example:
Expand|Select|Wrap|Line Numbers
  1. H  I  J K L    M N O  P  Q R S  T   U  V  W X Y   Z  A   B  C   D  E  F   G
  2.  
  3. A B C D  E   F G H   I   J  K L  M  N  O  P  Q  R  S T  U   V  W  X  Y   Z 
  4. Where H = A. R = K. A=T. G=Z.
  5.  
This "extremely sophisticated" code has finally been broken by the professor and now the the students wants a code as follows:
1. Enter a key phrase ( no spaces)
2. Remove all the duplicate letters in the key phrase.
3. Remove the letters that remain in the edited key phrase from the string of the 26 alphabet letters.
4. Connect the edited key phrase to the front of the edited alphabet.
5. Use this new string to transform letters in the code to the alphabet (similar to the above example)
Example:
1. Key Phrase: DOCTORZOOSSCIENCEREVIEWS
2. Remove duplicates: DOCTRZSIENVW
3. Remove these letters from the alphabet: ABFGHJKLMPQUXY
4. Connect these two: DOCTRZSIENVWABFGHJKLMPQUXY
5. Use to decode; ABCDEFGHIJKLMNOPQRSTUMXYZ
CODE : CDMLEFB LIR AFMBLDEBK DJR ZMWW FZ IEWWK
TRANSL : CAUTION THE MOUNTAINS ARE FULL OF HILLS
Write a program called "DECODE" that will allow for the keyboard entry of the key phrase (which Mr. Brown will supply to you), read one line of code from a text file, decode it and display the translation to the screen and printer. The
text files are individual and named as follows:
c:\\f(9999).txt example: f1234.txt
Here is one way of removing duplicates from a string;
1. Enter string1 and set string2 equal to a null string.
2. Set up a nested for loop. Loop1 from 0 to 1 less than the string1 length. Loop2 from Loop1 + 1 to 1 less than the string1 length (same as the Bubble Sort loops)
3. If the letters pointed to by both loops are equal, set the Loop2 letter to an *
4. After the loops are finished, start another loop from 0 to length of string1
5. If the letter is NOT an *, then concatenate it to the end of string2.

Here's an idea:
Expand|Select|Wrap|Line Numbers
  1. string stringl, string2;
  2. string2 = “ “ // making string2 a null string
  3. cout << "Enter string1; ";
  4. getline(cin, string1);
  5. for(i=0; I < string1.Iength()-1; i++)
  6. for(j=i+1; ]< string1.length();j++)
  7. {
  8. if(string1[i] ! =’ ‘ ) // skipping spaces
  9. {
  10. if (string1[i] == string1 [j]) // finding duplicates
  11. string1[j] = ‘*’; // making the duplicate letter a '*'
  12. )// end if
  13. ) // end for j
  14. // Removing the *'s, spaces and creating a new string
  15. for(i=0; i < string1.length(); i++)
  16. {
  17. if(string1[i] != '*' && stringi [i] != ' ') // checking for an asterick (*) and a space
  18. string2 += string1[i];
  19. } // end for i
  20. cout <<string2 << endl;
  21.  
Thanks for any ideas, jumpstart and help. Have a good day.
Nov 8 '07 #1
1 1428
Ganon11
3,652 Expert 2GB
If this is code you've written, you're using the ` symbol a lot where you should use ' or ". Also, I think I see a place where you typed string1.Iength() (with an uppercase i instead of a lowercase L beginning length()). Basically, there are a lot of silly typos in that code that look like they resulted from poor copying from a book or other source.

Anyway, besides that code, what else have you written? What do you need help with so far?
Nov 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: steve | last post by:
Hi, I am opening a stream that is UTF encoded. I use fgetc to read the stream- which is binary safe. I add every character read to a string. But when I look at the stream, I see some...
1
by: Thomas Williams | last post by:
Hello everyone, my name is Tom W. And, I am new to the list, and have been using Python for about a year now. Anyway, I got a question! I am trying to decode MIME (base64) email from a POP3...
40
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. ...
0
by: Johann Blake | last post by:
In my need to decode a JPEG 2000 file, I discovered like many that there was no functionality for this in the .NET Framework. Instead of forking out a pile of cash to do this, I came up with the...
5
by: Peter Jansson | last post by:
Hello group, The following code is an attempt to perform URL-decoding of URL-encoded string. Note that std::istringstream is used within the switch, within the loop. Three main issues have been...
14
by: BB | last post by:
Hello. i am trying to decode a block of (what i think is) base64 into text, and i have NO idea how to begin. I'm going to paste the whole string here, but i want to know the steps necessary to...
25
by: marcin.rzeznicki | last post by:
Hello everyone I've got a little problem with choosing the best decoding strategy for some nasty problem. I have to deal with very large files wich contain text encoded with various encodings....
9
by: KWSW | last post by:
Having settled the huffman encoding/decoding and channel modeling(thanks to the previous part on bitwise operation), the last part would be hamming encoding/decoding. Did some research as usual on...
0
by: Michele | last post by:
Hi there, I'm using a python script in conjunction with a JPype, to run java classes. So, here's the code: from jpype import * import os import random import math import sys
42
by: Santander | last post by:
how to decode HTML pages encoded like this: http://www.long2consulting.com/seeinaction2008/Simplicity_Beach_table/index.htm Is there script that will do this automatically and generate normal fully...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.