Hii I please help me to make this string program I have to input "computer is fun" and output should be "is fun computer".
![]() |
Hii I please help me to make this string program I have to input "computer is fun" and output should be "is fun computer".
Look at String tokenization functions in the string library. What you can do with that is bust your string into tokens separated by a character, being white space in your case, and then you can do what you want with it. Is there a specific rule you have to use for this program?
Please help me in coding which string function we can use to manage these separate tokens in that order
What is the assignment? The answer changes based on this.
Thank you for your help but I'm looking for a program code for this explanation please help me in that I understand what you said but not able to convert it in program
The assignment specs tell me if you they want you to just juxtapose the first work last or if they want something more.
I am not going to post code. You have to write that yourself. There are several ways this could work, puesdo-code is:
// This will do what you want, but it will probably cause you to fail the assignment.
if( inputString == "Computer Is Fun")
systemPrint("Is Fun Computer");
//This could be a pass, but it isn't the most efficient way of doing it.
string firstWord;
string theRestOfIt;
bool haveFirstWord = false;
for(int I=0; I < inputString.Length; I++)
{
if(haveFirstWord)
theRestOfIt.append(inputString[i]);
else
firstWord.append(inputString[i]);
if(inputString[i] == ' ')
haveFirstWord = true;
}
systemPrint(theRestOfIt + firstWord);
// But wait, I googled the string class for Java.
string firstword = inputString;
firstword.replace(' ','\0'); // isolate the first word.
string theRestOfit = inputString.substring(firstword.length());
systemPrint(theRestOfIt + firstWord);
//------
Seriously, Google the Java string class, there is so much in there that can help you. It will all change if you need more versatility in your program as well.
Thank you for your kind help that will definitely help me
All times are GMT -7. The time now is 10:40 AM. |