Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

mew55 Group Title

C++ thank u ganeshie8 for helping me :D. everything ran great but there one teeny tiny thing i need help on. its the output file. the program created the output for the index location. i need the output file to have not only the index location of a word but also this.

  • one year ago
  • one year ago

  • This Question is Closed
  1. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    • one year ago
    1 Attachment
  2. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    you need to add another loop

    • one year ago
  3. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    how do i add the loop and where do i put it?

    • one year ago
  4. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    below statements are not part of loop :- cout<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; cout << "Please enter a word to be checked with the handy-dandy dictionary please"<< " : "; cin>> temp;

    • one year ago
  5. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    you need to put them in a loop.. il modify and post u code wait

    • one year ago
  6. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    thank u so much

    • one year ago
  7. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    #include<iostream> #include<fstream> #include<cstdlib> #include<string> using namespace std; int main() { const int size = 20; int num_words=0; int index = 0; int done = 0; string ifilename, ofilename, line; ifstream inFile, checkOutFile; ofstream outFile; char response; string temp; int idx=-1; int i; int k; string quit; string dict[size]; // Input file cout << "Please enter the name of the file you wish to open : "; cin >> ifilename; inFile.open(ifilename.c_str()); if(inFile.fail()) { cout << "The file " << ifilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } // Output file cout << "Please enter the name of the file you wish to write : "; cin >> ofilename; checkOutFile.open(ofilename.c_str()); if(!checkOutFile.fail()) { cout << "A file " << ofilename << " exists.\nDo you want to continue and overwrite it? (y/n) : "; cin >> response; if(tolower(response) == 'n') { cout << "The existing file will not be overwritten. " << endl; exit(1); } } outFile.open(ofilename.c_str()); if(outFile.fail()) { cout << "The file " << ofilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } for(i = 0; i < size; i++) { inFile >> dict[i]; } for(k=0; k<size;k++) { cout<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; cout << "Please enter a word to be checked with the handy-dandy dictionary please"<< " : "; cin>> temp; idx=-1; for(i=0; i<size;i++) { if(temp == dict[i]) { idx=i; cout<<" The word ("<< temp <<") is found in the dictionary at "<<i<<endl; outFile<< "The word ("<<temp<<") is found in the dictionary at "<<i<<endl; } } if(idx==-1) { if (temp == "quit") { cout<<"Thank you for using my Dictionary. Good bye."<<endl; break; } cout<<" The word ("<< temp <<") is not found in the dictionary "<<endl; outFile<<" The word ("<< temp <<") is not found in the dictionary "<<endl; } } }

    • one year ago
  8. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    no if or else statements?

    • one year ago
  9. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    oh nvm i c them XD.

    • one year ago
  10. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    herez the output i see when i execute

    • one year ago
    1 Attachment
  11. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    sorry i frozed for some reason. yeah its good but instead of the welcome, i want the program to go back to the part where i have to type another word.

    • one year ago
  12. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    like this ?

    • one year ago
    1 Attachment
  13. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    YES YES YES :D!!!

    • one year ago
  14. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    just move the Welcome line out above the for loop

    • one year ago
  15. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    #include<iostream> #include<fstream> #include<cstdlib> #include<string> using namespace std; int main() { const int size = 20; int num_words=0; int index = 0; int done = 0; string ifilename, ofilename, line; ifstream inFile, checkOutFile; ofstream outFile; char response; string temp; int idx=-1; int i; int k; string quit; string dict[size]; // Input file cout << "Please enter the name of the file you wish to open : "; cin >> ifilename; inFile.open(ifilename.c_str()); if(inFile.fail()) { cout << "The file " << ifilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } // Output file cout << "Please enter the name of the file you wish to write : "; cin >> ofilename; checkOutFile.open(ofilename.c_str()); if(!checkOutFile.fail()) { cout << "A file " << ofilename << " exists.\nDo you want to continue and overwrite it? (y/n) : "; cin >> response; if(tolower(response) == 'n') { cout << "The existing file will not be overwritten. " << endl; exit(1); } } outFile.open(ofilename.c_str()); if(outFile.fail()) { cout << "The file " << ofilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } for(i = 0; i < size; i++) { inFile >> dict[i]; } cout<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; for(k=0; k<size;k++) { cout << "Please enter a word to be checked with the handy-dandy dictionary please"<< " : "; cin>> temp; idx=-1; for(i=0; i<size;i++) { if(temp == dict[i]) { idx=i; cout<<" The word ("<< temp <<") is found in the dictionary at "<<i<<endl; outFile<< "The word ("<<temp<<") is found in the dictionary at "<<i<<endl; } } if(idx==-1) { if (temp == "quit") { cout<<"Thank you for using my Dictionary. Good bye."<<endl; break; } cout<<" The word ("<< temp <<") is not found in the dictionary "<<endl; outFile<<" The word ("<< temp <<") is not found in the dictionary "<<endl; } } }

    • one year ago
  16. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    omg u r a life save. thank u so much :D

    • one year ago
  17. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    yw !

    • one year ago
  18. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    aaw u dont have to give me a medal. u deserve it :D

    • one year ago
  19. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    • one year ago
    1 Attachment
  20. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    u coded very good most part of the working code... thats why i gave u :)

    • one year ago
  21. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    do i need to put an array or set presion?

    • one year ago
  22. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    i dint get u... array for wat ?

    • one year ago
  23. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    u want output file also to have wat..

    • one year ago
  24. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    oh array is for numbers. but ....let me try again. from the pdf i just attached and on the bottom of the screen, it shows every like wut the command prompt said. here is wut they gave me.

    • one year ago
  25. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    ok i wait. i dint get wat u saying though.. :(

    • one year ago
  26. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    when i put outfile to the welcome, the please section, the cin>>temp; the index location, the word not found section, and the quit section, it worked but when i open the output file, its like each section is all in big long sentences

    • one year ago
  27. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    okay u c the pdf file?

    • one year ago
  28. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    okie i opened pa13.pdf

    • one year ago
  29. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    and on the very bottom of the page it shows the output and the output file (notepad)

    • one year ago
  30. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    yea im there

    • one year ago
  31. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    oh u saying in ur output file, you not getting this "Please.. " line eh ?

    • one year ago
  32. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    yes plus the welcome and the word i type

    • one year ago
  33. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    ok il modify wait

    • one year ago
  34. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    kk thank u. i hope i am not asking much :S

    • one year ago
  35. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    output file like this ?

    • one year ago
    1 Attachment
  36. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    if so, modified code :-

    • one year ago
  37. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    #include<iostream> #include<fstream> #include<cstdlib> #include<string> using namespace std; int main() { const int size = 20; int num_words=0; int index = 0; int done = 0; string ifilename, ofilename, line; ifstream inFile, checkOutFile; ofstream outFile; char response; string temp; int idx=-1; int i; int k; string quit; string dict[size]; // Input file cout << "Please enter the name of the file you wish to open : "; cin >> ifilename; inFile.open(ifilename.c_str()); if(inFile.fail()) { cout << "The file " << ifilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } // Output file cout << "Please enter the name of the file you wish to write : "; cin >> ofilename; checkOutFile.open(ofilename.c_str()); if(!checkOutFile.fail()) { cout << "A file " << ofilename << " exists.\nDo you want to continue and overwrite it? (y/n) : "; cin >> response; if(tolower(response) == 'n') { cout << "The existing file will not be overwritten. " << endl; exit(1); } } outFile.open(ofilename.c_str()); if(outFile.fail()) { cout << "The file " << ofilename << " was not successfully opened." << endl; cout << "Please check the path and name of the file. " << endl; exit(1); } else { cout << "The file is successfully opened." << endl; } for(i = 0; i < size; i++) { inFile >> dict[i]; } cout<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; outFile<<"Welcome to Dictionary. Please enter any word or quit if wished to leave the program. \n"<< endl; for(k=0; k<size;k++) { cout << "Please enter a word to be checked with the handy-dandy dictionary please"<< " : "; outFile << "Please enter a word to be checked with the handy-dandy dictionary please"<< " : "; cin>> temp; outFile<< temp << endl; idx=-1; for(i=0; i<size;i++) { if(temp == dict[i]) { idx=i; cout<<" The word ("<<temp<<") is found in the dictionary at "<<i<<endl; outFile<< "The word ("<<temp<<") is found in the dictionary at "<<i<<endl; } } if(idx==-1) { if (temp == "quit") { cout<<"Thank you for using my Dictionary. Good bye."<<endl; break; } cout<<" The word ("<< temp <<") is not found in the dictionary "<<endl; outFile<<" The word ("<< temp <<") is not found in the dictionary "<<endl; } } }

    • one year ago
  38. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    sorry was peeling carrots. and yes

    • one year ago
  39. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    lol ok i just added two extra lines in this, for outputting the Welcome line and the input entry line.. see if it makes sense

    • one year ago
  40. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    oh maybe thatz y it wasnt working, i didnt put the endl; in the cin temp of the outfile

    • one year ago
  41. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    oh ya i did the same and it dint work... and then i corrected...

    • one year ago
  42. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    kk i am going to test it out now. thank u so much :D

    • one year ago
  43. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    np just holler if need anything

    • one year ago
  44. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    kk :D

    • one year ago
  45. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    ?

    • one year ago
  46. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    sorry. its long XD

    • one year ago
  47. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    ha ok whtas wrong in helping...

    • one year ago
  48. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    but she want me to do everything and give her the assignment

    • one year ago
  49. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    is that bad?

    • one year ago
  50. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    oh. then it is bad only. but its okay we can be flexible and help each other out right... especially in crunch times... she says she is occupied fully... i would help...

    • one year ago
  51. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    wat program is it

    • one year ago
  52. mew55 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    and i really appreciate that :3

    • one year ago
  53. ganeshie8 Group Title
    Best Response
    You've already chosen the best response.
    Medals 2

    oh ok.. then u can give her program and explain it hink... i gotta slp 1 am over here... gn

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.