Write a program that read 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


Output:

Please enter a line of text
I am A.I


i AM a.i

This is a palindrome

Comments
-mike555

Can you post your initial attempt?
Language (C or C++)?
You may want to investigate the functions isupper, islower, toupper and tolower.

Can you post your initial attempt?
Language (C or C++)?
You may want to investigate the functions isupper, islower, toupper and tolower.

C++
hope u can help me by giving example....

When you write "example," what exactly do you mean? You're not going to be given the answer.

Erm....can u tell me wat should i do 1st??

doin the 1st part 1st....
made the word reverse....
like below
anyway..did u understand my question?

Output:

Please enter a line of text
I am A.I


i AM a.i

This is a palindrome

Start with code that has something like this:

#include <iostream>
using namespace std;

int main()
{
   // MY EFFORT HERE
}

This sure i know.....i mean the link-list......
READ MY QUESTION N UNDERSTAND CAREFULLY!!!
u just give the basic....all ppl know....tat....

Do you want an A.I program or do you want a program that just changes each uppercase letter to lowercase...Because A.I programing is very different...Do want the program to remember past inputs and be indepth?

Do you want an A.I program or do you want a program that just changes each uppercase letter to lowercase...Because A.I programing is very different...Do want the program to remember past inputs and be indepth?

this is not A.I program....is C++ program...
i mean the words such as ABC change to abc

example of output

please enter a line of text
A War At TARAWA <---enter by user

a wAR aT tarawa

This is the palindrome

can u see the differents between 2 sentences??
capital letter to small letter
palindrome is read backwards also the same sentences

mad adam

MAD ADAM <---try read backwards same as previous

Can you post your initial attempt?
Language (C or C++)?
You may want to investigate the functions isupper, islower, toupper and tolower.

C++
can show me how did u to in stack.h , queue.h , and the palindrome.cpp seperately?? refer to my program above
wrote the program..pls

include the touppercase and tolowercase to convert the letter to A to a


thanks in advance..

Hi... there... I'm omick from the Philippines... Actually I'm a newbie here... I really dont know what you people are talking about... But anyways i'll be giving my idea of how to make a palindrome... I mean not really the whole thing... and i'm not that sure if this stuff thats on my mind will work out... ok here it is:

define your main function and include all those prompt thingy...:
like this one... i'm not so sure with this...

bool it_is_palindrome(string palindrome2)
int main()
{
string palindrome;
//prompt the user for a line of input
e.g.:
cout << "Enter now your word: ";
getline(cin, palindrome);
//now to test whether it is a palindrome you make a validation function... e.g. bool;
if (it_is_palindrome(palindrome))
cout << "It is a palindrome!";
else
cout << "Not a palindrome";
return 0;
}

<< moderator edit: added code tags: [code][/code] >>

uhmmm.... i'm using a cafe... sorry i dont have much time left... maybe next time ok...

but wait...

arrays are very useful here...

this function should be included:
*function that will convert all your letters into small letters
e.g.

for (int i=0; i<lengt_of_string; i++)
     letter[i]=(tolower(another_letter[i]);

*function that will remove any punctuation marks including spaces

Tell me if you like my sample solution... I can really solve the problem... But I dont have enough time... If you like it... I can provide you the whole program... ok... e-mail me: << moderator edit: email snipped >>

Comments
-mike555

You could implement a stack, then pop each element off the top while at the same time pushing the element on to another stack. Then compare the results.

Naturally, there are much better ways to do what you want.

Comments
-mike555

Hi... there... I'm omick from the Philippines... Actually I'm a newbie here... I really dont know what you people are talking about... But anyways i'll be giving my idea of how to make a palindrome... I mean not really the whole thing... and i'm not that sure if this stuff thats on my mind will work out... ok here it is:

define your main function and include all those prompt thingy...:
like this one... i'm not so sure with this...

bool it_is_palindrome(string palindrome2)
int main()
{
string palindrome;
//prompt the user for a line of input
e.g.:
cout << "Enter now your word: ";
getline(cin, palindrome);
//now to test whether it is a palindrome you make a validation function... e.g. bool;
if (it_is_palindrome(palindrome))
cout << "It is a palindrome!";
else
cout << "Not a palindrome";
return 0;
}

<< moderator edit: added code tags: [code][/code] >>

uhmmm.... i'm using a cafe... sorry i dont have much time left... maybe next time ok...

but wait...

arrays are very useful here...

this function should be included:
*function that will convert all your letters into small letters
e.g.

for (int i=0; i<lengt_of_string; i++)
     letter[i]=(tolower(another_letter[i]);

*function that will remove any punctuation marks including spaces

Tell me if you like my sample solution... I can really solve the problem... But I dont have enough time... If you like it... I can provide you the whole program... ok... e-mail me: << moderator edit: email snipped >>

The palindrome part i know to do...but the problem i having is the alphabet...from A to a
i didnt know where to put the function...

i done with #include 'Stack.h', #include 'Queue.h' and Main.cpp
i show main program n add me the function (tolowercase,touppercase)

my main.cpp as below..

#include <iostream>
#include <cstdlib> // For EXIT_FAILURE and EXIT_SUCCESS
#include <fstream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cctype>

using namespace std;

#include "Queue.h"
#include "Stack.h"


/***************************MAIN******************************/
int main()
{
	Stack S;	// initialize stack
	Queue Q;	// initialize queue
	string s;
	int i=0;	// initialze int 'i'
	char string[MAX];  // initialize char string
	bool RESULT=false;  // initilize bool RESULT to false

	
	strcpy(string," ");
	cout << "Please enter a line of text: " << endl; 
	cin.getline (string,100);

for( int j = 0; j < s.size(); ++j)
	  {
	    if(s[j] >= 'A' && s[j] <= 'Z')
	      s += (s[j] | 32);
	    else
	      if(s[j] >= 'a' && s[j] <= 'z')
		s += (s[j] & (~32));
	      else
		s += s[j];
	  }

while(string[i]!=NULL)
	{
		S.push(string[i]);  // push chars individually from string to
		Q.addq(string[i]);		// stack and queue
		i++;      // next char
	}
	while(i>0)
	{
		if(S.topNpop()==Q.frontNremoveq())  // compare each element from
		{										// stack and queue
			RESULT=true;  // if same for all chars return true
		}
		else
		{
			RESULT=false;  // if not same for any char break and return false
			break;
		}
		i--;
	}	


if(RESULT==true)
	{
		cout<<string<<" \nThis is a palindrome\n";  // display if true
	}
	else
	{
		cout<<string<<" \nThis is not a palindrome\n"; // display if false
	}
	
	cout<<s<<s<<endl;

	return 0;
}

hi hey... sorry for the late reply... i'm so busy processing my clearance to get home... kindly check for any mispelled things ok??? I have only type this stuff for you... so i cannot assure you that is free from errors... i havent tested this program... ok>>> but i know this would surely work!

heres the function that will convert any capital letters into small ones

//your main_function here
//dont forget to use getline(cin, your_string_here);
//if (is_your_string_palindrome(your_string_here));
//cout << "Palindrome!";
//else
//cout << "not!";
//and one thing... dont forget your header string ok? #include <string> :cheesy: 



//heres the function that will remove all punctuation marks

string punctuation_erase (const string& your_string, const string& punctuation)
{
string no_punctuation; //this will create an empty string ok.
int your_string_length = your_string.length();
int punctuation_length = punctuation.length();
for (int i =0; i < your_string_length; i++)
{
 string report_char = your_string.substr(i, 1) //pick-up a one character
 int character_location = punctuation.find(report_char, 0);
   if (character_location < 0 || character_location >= punctuation_length)
     no_punctuation = no_punctuation + report_char // concatenates (+) strings that cannot be found in punctuation
}
return no_punctuation;
}

//the function that will determine whether the input line is a palindrome

bool is_your_string_palindrome(cons string& your_string)
{
string punctuation ("?,:;'!\" "); // theres a space ok.. you can add other punctuations here.
string string_here(your_string);
string_here = make_lower_letters(string_here);
string lowerstring_puncterase = punctuation_erase(string_here, punctuation);
return (lowerstring_puncterase==reverse(lowerstring_puncterase);
}

string make_lower_letters (const string& your_string)
{
string new_string(your_string);
for (int i=0; i < your_string.length(); i++)
        new_string[i] = tolower(your_string[i]);
return new_string;
}

string reverse(const string& your_string)
{
int first = 0;
int last = your_string.length();
string string_here(your_string);
while (first < last)
{
last--;
swap(string_here[first], string_here[last];
first++;
}
return string_here;
}

void swap_letters(char& letter1, char& letter2)
{
char letter_here = letter1;
letter1 = letter2;
letter2 = letter_here;
}

<< moderator edit: added code tags: [co[u][/u]de][/co[u][/u]de] >>

sent a palindrome program in vb

So you bump a 2.5 year old thread and then expect to get some free homework?
You're not even in the right forum, this is C++ not VB.

quick

[...]

Here's what you could try:
- Begin programming it yourself
- If you get stuck go to the right forum (VB) and look for the answer
- If the question was not answered in other thread, start a new thread and ask your question
- Don't use words like "Quick"

And to get you started, you might want to look here

Edited 6 Years Ago by Nick Evan: n/a

You don't seem to get the hint. aniweb is to assist newbies by mentoring them.
This is not a place to get others to do your homework.
You learn programming by doing, not copying others.

This article has been dead for over six months. Start a new discussion instead.