i have this assigment and i need someone to help me in the solution as soon as possible because the assigment is due in 7/1/2008


the problem is


D] A Tale from the Dark Side of The Moon
Program: pink.(c|cpp|java)
Input: pink.in
Balloon Color: Pink
Us: So why don’t you just recompile the program
on the new hardware?
Them: We cannot. We lost the source code.
Us: How typical! What does the program do? Do
you have any documentation?
Them: The manual page does mention something
about the documentation in the source code.
Us: A manual page is good. What does it say?
Them: Just one line: “See the source code for more
information.”
Us: Argh! What do you know about the program?
Them: Well, it seems to be taking simple text, similar
to that found in an English dictionary, and
printing it after some modification.
Us: What kind of modification?
Them: It removes any character that is not a lowercase
letter. But not white spaces. White spaces
are preserved as seen in the input.
Us: Do you have a sample input/output?
Them: Plenty. Here’s one. (see next page.)
Us: This is rather small! Did you try it on anything
bigger?
Them: It works on any text as long as the lines are
less then eighty characters wide. It doesn’t seem
to mind working on lengthy documents. But it
does terminate once it sees the sequence "EOF"
(without the double quotes.)
One of them: Don’t forget to tell them about the
"dd" thingy.
Us: : What "dd" thingy?
Them: Whenever it sees a pair of small letter "d",
one right after the other, it replaces them with "p".
Us: Why?
Them: Who knows? It just does that!
Us: What about "ddd" and "dddd"? How does it
behave then?
Them: Where in English will you find a "dddd" or
even a "ddd"? Haven’t you been listening?
Us: Oops. We’ll pay more attention. Anything else?
Another one of them: There is also the "vv" thingy.
Us: What about "vv"?
Them: Every "vv" is replaced with a "m".
Yet another one of them: No, wait! That was a printer
problem. it had nothing to do with the program.
Remember?
Them: Oh, that’s right. Forget about the "vv"
thingy.
Us: What about the "dd" thingy? Was that just a
printer problem too?
Them: No. That was the program.
Us: What else?
Them: One last thing. It seems to be replacing
every "ei" with "ie".
Us: Every one of them?
Them: Except if it comes right after "c" then it remains
as is.
Us: Makes sense. That’s all, right?
Them: No, we just remembered one more thing: It
replaces the sequence "pink" with "floyd" anywhere
in the text.
Us: What?! Who wrote this program? Why do you
need it in the first place?
Them: We think it will increase our chances of going
to Banff in April 2008 if we get it right.
Us: Yeah! Right.
Page 4 of 14
Sample Input/Output
pink.in
unpinked is an 8 letter word. Honest!
vv is ok, d123d is ok, 123dd is not
i received mail from liechtenstein
.. ...adding means to imitat.#$!%%$e
EOF
OUTPUT
unfloyded is an letter word onest
vv is ok dd is ok p is not
i received mail from liechtenstien
aping means to imitate

Interesting reading and a unique way of presenting a problem, but I'm still not going to do your homework for you.

i dont want you to solve my homework

just give me a clear hint to solve it

What you first need to do, is to extract all the requirements from this text you've been given, to split the assignment in smaller problems:

Problems:

- Read a text file
- remove all chars except for spaces and lowecase
- find a function that reads a file line by line (max 80 chars)
- look for 'dd' and replace with 'p'
- 'ie' => 'ei' except when the previous char is a 'c'
- 'pink' becomes 'floyd'

So how you want to start is to make a program that opens a file, then loops through it, changing all the thing mentioned above.

Good luck with it, come back if you have any questions

the problem with me is how to read char by char and then replace them with another one or remove

i tried this way but i dont know if it is right or wrong

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


int main ()
	{

  char Sen[80];
  char Rsen[80];
  int len;

  cout << "Enter your name: ";
  
  cin.getline (Sen,80,'EOF');
  len=strlen(Sen);
  
  if(Sen >="A" && Sen<="Z")
 {
	  for(int i=0;i<28;i++)
		  Sen[i]=Rsen[i];
	  cout << Rsen[i]<< " " << endl;
  }



  
  

  return 0;
}

There is more then one way to do this:

You could read in the entire file in a char[] buffer and then parse it. This is only an option if you have a (relative) small file.

You could read the file line by line and parse these lines.

You could read the file one char at a time and parse this. But this wouldn't really be an option in your case because you have to check complete words like pink and floyd .

So I would recommend using getline()


[edit] aha more info....[/edit]

i tried this way but i dont know if it is right or wrong

I would say that thiss won't even compile. Sen[i]=Rsen[i]; : That's horrible. Rsen never got a value so the output is completely random. if(Sen >="A" && Sen<="Z") : What are you trying to do here? Keep in mind that Sen is a char[] not a single char. So you're comparing the pointer to the first element of an array with 'A' &&'Z'. cin.getline (Sen,80,'EOF'); Just use cin.getline (Sen,80); If you have your input in the char[] buffer, just loop through this buffer and check every single char for uppercase. If it is a uppercase just add (int)76 to the char and it will become lowercase.

the question said that i have to remove every uppercase that is why i made this statment
if(Sen >="A" && Sen<="Z")

You didn't post that question

I'll give you a little start, because you've shown some effort and you're allmost on the right track :

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

int main ()
{

    char Sen[80];
    int len = 0;

    cout << "Enter your name: " << endl;

    cin.getline (Sen,80);
    len=strlen(Sen);

    for (int i = 0; i < len; i++)
    {
        if(Sen[i] >= 'A' && Sen[i] <= 'Z')
        {
             cout << "This one is uppercase: " << Sen[i] << endl;
        }
    }
    return 0;
}

As you can see I've added a loop that loops trough all the single chars in your 'Sen'Buffer. Then the if statement looks if the char is a CAP.

Next time you post code : please use [ code][ /code] tags. It's makes your code easier to read. Also use indention.

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


int main ()
{

  char Sen[80];
  char Rsen[80];
  int len;
  int k=0;
  
  cin.getline (Sen,80,'EOF');
  len=strlen(Sen);
  
for (int i = 0; i < len; i++)
{
        if(Sen[i] >= 'A' && Sen[i] <= 'Z')
        
			i++;
		  else if (i>=0 && i<9)
           i++;

	
		else
		{	
			Rsen[k]=Sen[i];
		     k++;
		     i++;
		}

          switch(Sen[i])
          {
               case 'dd':
               Sen[i] = 'p';
               break;
          }
		  cout << Sen[i]<< endl;
}
     
 
  
  

  return 0;
}

this is my try but still not working fine

heeeeeeeeeeeeeeeeeelp meeeeeeeeeee

heeeeeeeeeeeeeeeeeelp meeeeeeeeeee

If you want to beg: go live on the street. Saying stuff like that doesn't help your case.

Now: What part of my code didn't you like? Did you read the link about code tags ?

for (int i = 0; i < len; i++)
{
if(Sen[i] >= 'A' && Sen[i] <= 'Z')

i++;
else if (i>=0 && i<9)
i++;

why are you incrementing 'i' 3 times? The only thing it does is that you'll get out of your array bounds and get horrible memory exceptions.

The only thing you have to do is replace the 'cout' from my code with somesort of logic.

i want to ask you aquestion???


do you solve the whole programme???

I probably could, and then get my behind kicked by the mods because that is against the rules.

Look: I gave a few hints and if you think it over I'm sure you'll get some good ideas. If you get stuck you can come here and ask a question.

Take the program I gave you and modify it. Take it one step at a time, don't try to make all the solutions at once.

Here's a freebee (2 extra lines of code):

#include<iostream>

using namespace std;

int main ()
{

    char Sen[80];
    char New[80];
    
    int len = 0, point =0;

    cout << "Enter your name: " << endl;

    cin.getline (Sen,80);
    len=strlen(Sen);

    for (int i = 0; i <= len; i++)
    {
        if (!(Sen[i] >= 'A' && Sen[i] <= 'Z'))
        {
                New[point] = Sen[i];
                point++;
        }
    }
    cout << New << endl;
    return 0;
}

Now the CAPS are gone.

Do you see how I used 2 counters (i and point) and 2 arrays?
Now try to look for 'dd' and replace it yourself.

when i apply your code the output is
mY Name Is SoSO
m ame s o╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
mY Name Is SoSO
Press any key to continue

thank you now the code is working

i want to ask you if i want also to remove numbers from a list .. i can use the same code or there is a different code??

when i apply your code the output is
mY Name Is SoSO
m ame s o╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠
mY Name Is SoSO
Press any key to continue

Yes I know, I made a small error. I typed for (int i = 0; i < len; i++) instead of for (int i = 0; i <= len; i++) . I corrected as soon as I spotted the typo, but you had already copied it :) You were just to fast

If you've inputted the numbers as char, you can use the exact same code, just change 'A' to '0' and 'Z' to '9'

the due date of my ass is over and i didnt submitted

but, i want the full answer for the question to my
if you can plz

thanks

the due date of my ass is over

:D So how are you going to sit on anything now?

but, i want the full answer for the question to my
if you can plz

I could. But I already explained why I'm not going to do that.

but really my due date for the assigment is over and i didnt submitted iwant the answer for my OWN information


any way thanks for helping

Now that due date for your project assignment is over I hope you have understood that no one will do your homework , practice programming few hours every day, you will become an expert, and you would not even ask for homework help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.