?
Solved

Big Program Input Buggy (HELP!!!)

Posted on 2005-03-31
3
Medium Priority
?
219 Views
Last Modified: 2010-04-01
I am creating a resume program that will ask the user questions then output to a text file, however for some reason when you run this program it skips questions and jumps to my y or n options instead. For example: it skips the first question which asks for the user to input his/her name.

Does anyone have any ideas how i can fix this and offer any suggestions/ideas that will make life easier with the output to file in this code?    Sincerely, Sinking in quicksand and going bald pulling hair out.


#include <iostream>
#include <stdlib.h>
#include <string>
#include <fstream>

using namespace std;

int main()
{

      int index;
      //for the cover page or the intro info, cover page can be bypassed as with all sections addressed.
      char myName[1][20], myAddress[1][50], myCityZip[1][20], myPhone[2][13], myEmail[1][30]; //personal info.
      char bName[5][20], bmyAddress[5][30], bAddress[5][30], bPhone[5][13]; //info of business addressed in resume.
      char POC[1][30]; //point of contact for default or both title and name of person being addressed in the business.
      char myStatement[1][50]; //for any opening remarks used to gain attention to the resume.
      char closing[1][50]; //closing statement.
      int test; //to test array close[] option.
      string FileName;

      //for the activities section.
      char myActivities[6][30];

      //for the education section.
      char mySchool[3][20];
      char myDegree[3][20];
      char myGdate[3][10];
      char myGPA[3][5];

      //for the experience portion of the resume.
      char myCompany[5][20];
      char myEmpDate[5][20];
      char myCityState[5][20];
      char myTitle[5][20];
      char myDuties[5][20];
      char mySummary[5][20];

      //for the skills section.
      char myNetworking[1][20];
      char myProgramming[1][20];
      char myHardware[1][20];
      char myGeneral[6][20];

      //for testing conditions to bypass or enter loops of the program.
      char re1, re2, re3, re4, re5, re6; //'re' for response in the first two sections of the resume builder.
      char re7, re8, re9, re10, re11, re12; //for the activities section.
      char re13, re14, re15; //for the education section.
      char re16, re17, re18, re19, re20, re21; //for the experience portion.
      char re22, re23, re24, re25, re26, re27, re28, re29, re30, re31; //for the skills portion.

      cout << "This program will guide you through a resume building process, please have your information handy. \n\nIf you would like to bypass any of the sections, you can do so when prompted. \n\n" << endl;
      cout << "This process will hold your information in an TXT file to be read and \nedited later by another program, e.g. Note Pad, Word, Lotus 123, ect. " << endl;

      //prompt to start optional cover page.
      cout << "\nThe basic format for a resume starts with a cover page.\nIf you do not want to start a cover page, the program will ask for \nyour personal information and an opening statement." << endl;
      cout << "\nWould you like to create a cover page? (y/n) :  ";
      cin >> re1;
      system("cls");

      if (re1 == 'y'){


         cout << "\n\nPlease enter your name as you want it to appear at the beginning \nas well as the bottom of the cover page :  ";

         cin.getline(myName[index], 20);

         system("cls");
         cout << "\n\nPlease note that there are two lines allowed for the addresses." << endl;
         cout << "\nPlease enter your street address :  ";
         cin.getline(myAddress[index], 50);

         system("cls");
         cout << "\n\nPlease enter the city, state and zip :  ";
         cin.getline(myCityZip[index], 20);

         system("cls");
         cout << "\n\nYou may also enter two contact numbers." << endl;
         cout << "\nPlease enter your primary home or cell phone number :  ";
         cin.getline(myPhone[index], 13);

         cout << "\n\nWould you like to include another phone number? (y/n) :  ";
         cin >> re2;
         system("cls");

         if (re2 == 'y'){
            index++;
            cout << "\n\nPlease enter your cell phone number :  ";
            cin.getline(myPhone[index], 13);
         }

         index = 1;
         cout << "\n\nWould you like to include your e-mail address as well? (y/n) :  ";
         cin >> re3;
         system("cls");

         if (re3 == 'y'){
            cout << "\n\nPlease enter your e-mail address :  ";
            cin.getline(myEmail[index], 30);
         }

         cout << "\n\nWould you like to enter the business information now? (y/n) :  ";
         cin >> re4;
         system("cls");

         if (re4 == 'y'){
            cout << "\n\nPlease enter the business name :  ";
            cin.getline(bName[index], 20);

            system("cls");
            cout << "\n\nPlease enter the business street address :  ";
            cin.getline(myAddress[index], 30);

            system("cls");
            cout << "\n\nPlease enter the city, state and zip :  ";
            cin.getline(bAddress[index], 30);

            system("cls");
            cout << "\n\nPlease enter the business phone number :  ";
            cin.getline(bPhone[index], 13);
         }

         cout << "\n\nFor the point of contact, if known, enter 'y', the default (n) will \nhold 'To Whom It May Concern;'.\n";
         cout << "\nPlease enter your response (y/n) :  ";
         cin >> re5;
         system("cls");

         if (re5 == 'y'){
            cout << "Please enter the title and name of the person to be addressed :  ";
            cin.getline(POC[index], 30);
         }

         cout << "\n\nWould you like to enter a short paragraph as the \nopening for the resume? (y/n) :  ";
         cin >> re6;
         system("cls");

         if (re6 == 'y'){
            cout << "\n\nPlease enter any remarks." << endl << endl;
            cin.getline(myStatement[index], 50);
         }

         cout << "\n\nWould you like to include a closing? (y/n) :  ";
         cin >> test;
         system("cls");

         if (test == 'y'){
            cout << "\nPlease enter your closing :  ";
            cin.getline(closing[index], 1);
         }
         //don't forget to print the myName string at the end as well for formality.
      }

      //if the user does not want to creat a cover letter, they can still enter their personal info and statement.
      else {
           index = 1;
           cout << "\n\nPlease enter your name :  ";
           cin.getline(myName[index], 20);

           system("cls");
           cout << "\n\nPlease note that there are two lines allowed for the address." << endl;
           cout << "\nPlease enter your street address :  ";
           cin.getline(myAddress[index], 50);

           system("cls");
           cout << "\n\nPlease enter the city, state and zip :  ";
           cin.getline(myCityZip[index], 20);

           system("cls");
           cout << "\n\nYou may also enter two contact numbers." << endl;
           cout << "\nPlease enter your primary home or cell phone number :  ";
           cin.getline(myPhone[index], 13);

           cout << "\n\nWould you like to include another phone number? (y/n) :  ";
           cin >> re2;
           system("cls");

           if (re2 == 'y'){
              index++;
              cout << "\n\nPlease enter your cell phone number :  ";
              cin.getline(myPhone[index], 13);
              system("cls");
           }

           index = 1;
           cout << "\n\nWould you like to include your e-mail address as well? (y/n) :  ";
           cin >> re3;
           system("cls");

           if (re3 == 'y'){
              cout << "\n\nPlease enter your e-mail address :  ";
              cin.getline(myEmail[index], 30);
           }

           cout << "\n\nWould you like to enter a short paragraph as the \nopening for the resume? (y/n) :  ";
           cin >> re6;
           system("cls");

           if (re6 == 'y'){
              cout << "\n\nPlease enter any remarks." << endl << endl;
              cin.getline(myStatement[index], 50);
           }
      }

      //now the activities step of the resume.
      cout << "\n\nWould you like to list the current activities you are involved in? (y/n) :  ";
      cin >> re7;
      system("cls");
      index = 1;

      if (re7 == 'y'){
          cout << "\n\nYou may list up to six activities.  Please enter your first activity :  ";
          cin.getline(myActivities[index], 30);
          cout << "\n\nWould you like to enter in another activity? (y/n) :  ";
          cin >> re8;
          system("cls");

          if (re8 =='y'){
             index++;
             cout << "\n\nPlease enter the next activity :  ";
             cin.getline(myActivities[index], 30);
             cout << "\n\nWould you like to enter another one in? (y/n) :  ";
             cin >> re9;
             system("cls");

             if (re9 =='y'){
                index++;
                cout << "\n\nPlease enter the next activity :  ";
                cin.getline(myActivities[index], 30);
                cout << "\n\nWould you like to enter another one in? (y/n) :  ";
                cin >> re10;
                system("cls");

                if (re10 =='y'){
                   index++;
                   cout << "\n\nPlease enter the next activity :  ";
                   cin.getline(myActivities[index], 30);
                   cout << "\n\nWould you like to enter another one in? (y/n) :  ";
                   cin >> re11;
                   system("cls");

                   if (re11 == 'y'){
                      index++;
                      cout << "\n\nPlease enter the next activity :  ";
                      cin.getline(myActivities[index], 30);
                      cout << "\n\nWould you like to enter another one in? (y/n) :  ";
                      cin >> re12;
                      system("cls");

                      if (re12 == 'y'){
                         index++;
                         cout << "\n\nPlease enter the next activity :  ";
                         cin.getline(myActivities[index], 30);
                      }
                   }
                }
             }
          }
      }

      index = 1;
      system("cls");
      //now the education section.
      cout << "\n\nWould you like to include your education? (y/n) :  ";
      cin >> re13;

      if (re13 == 'y'){
         cout << "\n\nIn this section, you can enter up to three schools.\nYou will be prompted for the name of the school, degree type, \nfinishing dates and GPA's.";
         cout << "\n\nPlease start with the last school you attended \nor are currently attending, then any previous schools." << endl;

         cout << "\nPlease enter the name of the school :  ";
         cin.getline(mySchool[index], 20);

         cout << "\n\nPlease enter the degree type gained :  ";
         cin.getline(myDegree[index], 20);

         cout << "\n\nPlease enter the graduation date or finishing date :  ";
         cin.getline(myGdate[index], 10);

         cout << "\n\nPlease enter the GPA :  ";
         cin.getline(myGPA[index], 5);

         cout << "\n\nWould you like to enter another school? (y/n) :  ";
         cin >> re14;
         system("cls");

         if (re14 =='y'){
            index++;
            cout << "\n\nPlease enter the name of the school :  ";
            cin.getline(mySchool[index], 20);

            cout << "\n\nPlease enter the degree type gained :  ";
            cin.getline(myDegree[index], 20);

            cout << "\n\nPlease enter the graduation date or finishing date :  ";
            cin.getline(myGdate[index], 10);

            cout << "\n\nPlease enter the GPA :  ";
            cin.getline(myGPA[index], 5);

            cout << "\n\nWould you like to enter another school? (y/n) :  ";
            cin >> re15;
            system("cls");

            if (re15 == 'y'){
               index++;
               cout << "\n\nPlease enter the name of the school :  ";
               cin.getline(mySchool[index], 20);

               cout << "\n\nPlease enter the degree type gained :  ";
               cin.getline(myDegree[index], 20);

               cout << "\n\nPlease enter the graduation date or finishing date :  ";
               cin.getline(myGdate[index], 10);

               cout << "\n\nPlease enter the GPA :  ";
               cin.getline(myGPA[index], 5);
            }
         }
      }

      system("cls");
      index = 1;
      //now the experience section.
      cout << "\n\nWould you like to enter information in the experience section? (y/n) :  ";
      cin >> re16;
      if (re16 == 'y'){
         cout << "\n\nYou are only allowed to enter six separate job positions.\nPlease enter the latest or current company first.";
         cout << "\n\nYou will be prompted for the name of the company, your beginning employee date,\nthe city and state worked from, ";
         cout << "the title of your position, your main duties \nand a brief summary of your experience." << endl;

         cout << "\nPlease enter the company name :  ";
         cin.getline(myCompany[index], 20);

         cout << "\n\nPlease enter the date of hire :  ";
         cin.getline(myEmpDate[index], 20);

         cout << "\n\nPlease enter the city and state of the company :  ";
         cin.getline(myCityState[index], 20);

         cout << "\n\nPlease enter you job title :  ";
         cin.getline(myTitle[index], 20);

         cout << "\n\nPlease enter your main duties :  ";
         cin.getline(myDuties[index], 20);

         cout << "\n\nPlease enter your brief summary of your experience there :\n";
         cin.getline(mySummary[index], 20);

         cout << "\n\nWould you like to add another company? (y/n) :  ";
         cin >> re17;

         system("cls");
         if (re17 == 'y'){
            index++;
            cout << "\n\nPlease enter the company name :  ";
            cin.getline(myCompany[index], 20);

            cout << "\n\nPlease enter the date of hire :  ";
            cin.getline(myEmpDate[index], 20);

            cout << "\n\nPlease enter the city and state of the company :  ";
            cin.getline(myCityState[index], 20);

            cout << "\n\nPlease enter you job title :  ";
            cin.getline(myTitle[index], 20);

            cout << "\n\nPlease enter your main duties :  ";
            cin.getline(myDuties[index], 20);

            cout << "\n\nPlease enter your brief summary of your experience there :\n";
            cin.getline(mySummary[index], 20);

            cout << "\n\nWould you like to add another company? (y/n) :  ";
            cin >> re18;

            system("cls");
            if (re18 == 'y'){
               index++;
               cout << "\n\nPlease enter the company name :  ";
               cin.getline(myCompany[index], 20);

               cout << "\n\nPlease enter the date of hire :  ";
               cin.getline(myEmpDate[index], 20);

               cout << "\n\nPlease enter the city and state of the company :  ";
               cin.getline(myCityState[index], 20);

               cout << "\n\nPlease enter you job title :  ";
               cin.getline(myTitle[index], 20);

               cout << "\n\nPlease enter your main duties :  ";
               cin.getline(myDuties[index], 20);

               cout << "\n\nPlease enter your brief summary of your experience there :\n";
               cin.getline(mySummary[index], 20);

               cout << "\n\nWould you like to add another company? (y/n) :  ";
               cin >> re19;

               system("cls");
               if (re19 == 'y'){
                  index++;
                  cout << "\n\nPlease enter the company name :  ";
                  cin.getline(myCompany[index], 20);

                  cout << "\n\nPlease enter the date of hire :  ";
                  cin.getline(myEmpDate[index], 20);

                  cout << "\n\nPlease enter the city and state of the company :  ";
                  cin.getline(myCityState[index], 20);

                  cout << "\n\nPlease enter you job title :  ";
                  cin.getline(myTitle[index], 20);

                  cout << "\n\nPlease enter your main duties :  ";
                  cin.getline(myDuties[index], 20);

                  cout << "\n\nPlease enter your brief summary of your experience there :\n";
                  cin.getline(mySummary[index], 20);

                  cout << "\n\nWould you like to add another company? (y/n) :  ";
                  cin >> re20;

                  system("cls");
                  if (re20 == 'y'){
                     index++;
                     cout << "\n\nPlease enter the company name :  ";
                     cin.getline(myCompany[index], 20);

                     cout << "\n\nPlease enter the date of hire :  ";
                     cin.getline(myEmpDate[index], 20);

                     cout << "\n\nPlease enter the city and state of the company :  ";
                     cin.getline(myCityState[index], 20);

                     cout << "\n\nPlease enter you job title :  ";
                     cin.getline(myTitle[index], 20);

                     cout << "\n\nPlease enter your main duties :  ";
                     cin.getline(myDuties[index], 20);

                     cout << "\n\nPlease enter your brief summary of your experience there :\n";
                     cin.getline(mySummary[index], 20);

                     cout << "\n\nWould you like to add another company? (y/n) :  ";
                     cin >> re21;

                     system("cls");
                     if (re21 == 'y'){
                        index++;
                        cout << "\n\nPlease enter the company name :  ";
                        cin.getline(myCompany[index], 20);

                        cout << "\n\nPlease enter the date of hire :  ";
                        cin.getline(myEmpDate[index], 20);

                        cout << "\n\nPlease enter the city and state of the company :  ";
                        cin.getline(myCityState[index], 20);

                        cout << "\n\nPlease enter you job title :  ";
                        cin.getline(myTitle[index], 20);

                        cout << "\n\nPlease enter your main duties :  ";
                        cin.getline(myDuties[index], 20);

                        cout << "\n\nPlease enter your brief summary of your experience there :\n";
                        cin.getline(mySummary[index], 20);
                     }
                  }
               }
            }
         }
      }

      system("cls");
      //now for the skills section.
      cout << "\n\nThe last optional section is the skills portion of the resume.";
      cout << "\n\nWould you like to enter your skills gained? (y/n) :  ";
      cin >> re22;
      system("cls");

      if (re22 == 'y'){
         cout << "\n\nThis section is broken down into separate sections including: \nNetworking, Programming, Hardware and any general skills you wish to add.";
         cout << "\n\nWould you like to include Networking skills? (y/n) :  ";
         cin >> re23;

         if (re23 == 'y'){
            cout << "Please enter your networking skills aquired :  ";
            cin.getline(myNetworking[index], 20);
         }

         system("cls");
         cout << "\n\nWould you like to include Programming skills aquired? (y/n) :  ";
         cin >> re24;

         if (re24 == 'y'){
            cout << "\n\nPlease enter your programming skills aquired :  ";
            cin.getline(myProgramming[index], 20);
         }

         system("cls");
         cout << "\n\nWould you like to include Hardware skills aquired? (y/n) :  ";
         cin >> re25;

         if (re25 == 'y'){
            cout << "\n\nPlease enter your hardware skills aquires :  ";
            cin.getline(myHardware[index], 20);
         }

         system("cls");
         index = 1;
         cout << "\n\nWould you like to include any general skills aquired? (y/n) :  ";
         cin >> re26;

         if (re26 == 'y'){
            cout << "\n\nIn this section, you can enter up to six general skills gained.";
            cout << "\n\nPlease enter the first skill :  ";
            cin.getline(myGeneral[index], 20);

            cout << "\n\nWould you like to enter another skill? (y/n) :  ";
            cin >> re27;

            if (re27 == 'y'){
               index++;
               cout << "\n\nPlease enter your second skill aquired :  ";
               cin.getline(myGeneral[index], 20);

               cout << "\n\nWould you like to enter another skill? (y/n) :  ";
               cin >> re28;

               if (re28 == 'y') {
                  index++;
                  cout << "\n\nPlease enter your third skill aquired :  ";
                  cin.getline(myGeneral[index], 20);

                  cout << "\n\nWould you like to enter another skill? (y/n) :  ";
                  cin >> re29;

                  if (re29 == 'y') {
                     index++;
                     cout << "\n\nPlease enter your forth skill aquired :  ";
                     cin.getline(myGeneral[index], 20);

                     cout << "\n\nWould you like to enter another skill? (y/n) :  ";
                     cin >> re30;

                     if (re30 == 'y') {
                        index++;
                        cout << "\n\nPlease enter your fifth skill aquired :  ";
                        cin.getline(myGeneral[index], 20);

                        cout << "\n\nWould you like to enter another skill? (y/n) :  ";
                        cin >> re31;

                        if (re31 == 'y') {
                           index++;
                           cout << "\n\nPlease enter your last skill aquired :  ";
                           cin.getline(myGeneral[index], 20);
                        }
                     }
                  }
               }
            }
         }
      }

      system("cls");

      cout << "\nEnter the Name of the File You Want to Create\n";
      cout << "Followed by the File Extension: ";
      cin >> FileName;

      //ofstream Resume(FileName, ios::out);
      ofstream Resume(FileName.c_str(), ios::out);

      Resume << myName[index] << "\n" << myAddress[index] << "\n" << myCityZip[index]
      << "\n" << myPhone[index]<< "\n" << myEmail[index]<< "\n" << bName[index]
      << "\n" << bmyAddress[index]<< "\n" << bAddress[index]<< "\n" << bPhone[index]
      << "\n" << POC[index]<< "\n" << myStatement[index]<< "\n" << closing[index]
     /* << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]
      << "\n" << myPhone[index]<< "\n" << myPhone[index]<< "\n" << myPhone[index]*/;

      system("PAUSE");
      return 0;
      }
0
Comment
Question by:xardious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 13677016
Hi xardious,
> >Does anyone have any ideas how i can fix this and offer any suggestions/ideas
> >that will make life easier with the output to file in this code?

Please state the problem you're having so we can give you a better answer.

David Maisonave :-)
Cheers!
0
 

Author Comment

by:xardious
ID: 13677649
The problem i am having is that the code completely skips a mojority of the input questions, such as what is your name, then it completely skips the rest of the input questions and goes to my yes or no prompt to continue to next section but even in the next section it completely skips all my inpu questions.  How do i fix this, i cant figure out whats causing this problem.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 1500 total points
ID: 13678347
you need to call ignore() function after calling cin >> somechar.
have a look to this previous question with the same problem:
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20716698.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question