Bio-Data Program

I've been stuck with this for a long time now. I'm just new to programming and our professor gave us an assignment to create a bio-data program. It's finished already but he gave one condition and that is when you enter letters or words in the Tel. Number part the program will terminate. I really don't know how I can do it though.

I tried using int and float for the tel_number but getline doesn't work with those types and when I use cin >>tel_number the program then skips the Provincial Address.

Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#include <cstdlib>
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <ctype.h>

using namespace std;


void gotoxy(int x, int y)
{
     COORD c = {x, y};
     SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), c);
}


int main(int argc, char *argv[])
{
    string name, position, city_address, provincial_address, birthdate, birthplace, civil_status, citizenship, height, weight, religion, sex, husbandorwifename, occu_spouse, spouse_address, name_birthdateofchildren, fathername, fatheroccu, mothername, motheroccu, parentaddress, parentnumber, language, emergencycontact, emeraddress, emernumber, elemschool, elemgraduate, highschool, hsgraduate, vocational, vocgrad, college, collgrad, course, specskill, others, from, to, pastpos, company, jobdesc, refname1, refoccu1, refaddress1, children_number;
    string tel_number;
    
    
    cout <<"PERSONAL DATA:" <<endl <<endl;
    cout <<" 1. Position Desired: " <<position <<endl <<" 2. Name: " <<name <<endl;                                                        
    cout <<" 3. City Address: " <<city_address <<endl <<"    Tel. Number: "  <<tel_number <<endl;
    cout <<" 4. Provincial Address: " <<provincial_address <<endl;
    cout <<" 5. Date of Birth: " <<birthdate;
    gotoxy(42,7);
    cout <<"Place: " <<birthplace <<endl;
    cout <<" 6. Civil Status: " <<civil_status;
    gotoxy(42,8);
    cout <<"Citizenship: " <<citizenship <<endl;
    cout <<" 7. Height: " <<height;
    gotoxy(42,9);
    cout <<"Weight: " << weight <<endl;
    cout <<" 8. Religion: " <<religion;
    gotoxy(42,10);
    cout <<"Gender: " <<sex <<endl;
    cout <<" 9. Name of Husband or Wife: " <<husbandorwifename <<endl <<"    His/Her Occupation: " <<occu_spouse ;
    gotoxy(42,12);
    cout <<"Address: " <<spouse_address <<endl;
    cout <<"10. Number of Children: " <<children_number <<endl <<"    Name & Date of Birth of Children: " <<endl <<name_birthdateofchildren <<endl;
    cout <<"11. Father's Name: " <<fathername;
    gotoxy(42,16);
    cout <<"Occupation: " <<fatheroccu <<endl;
    cout <<"11. Mother's Name: " <<mothername;
    gotoxy(42,17);
    cout <<"Occupation: " <<motheroccu <<endl
    <<"    Their Address: " <<parentaddress <<endl <<"    Tel. Number: " <<parentnumber <<endl;
    cout <<"13. Languages or Dialects you can speak or write: " <<language <<endl <<"14. Person to be contacted in case of emergency: " <<emergencycontact <<endl;
    cout <<"    His/Her Address: " <<emeraddress <<endl <<"    Tel. Number: " <<emernumber <<endl <<endl <<endl <<"EDUCATIONAL BACKGROUND:" <<endl <<endl;
    cout <<" Elementary School: " <<elemschool;
    gotoxy(42,28);
    cout <<"Date Graduated: " <<elemgraduate <<endl;
    cout <<" High School: " <<highschool;
    gotoxy(42,29);
    cout <<"Date Graduated: " <<hsgraduate <<endl;
    cout <<" Vocational: " <<vocational;
    gotoxy(42,30);
    cout <<"Date Graduated: " <<vocgrad <<endl;
    cout <<" College: " <<college;
    gotoxy(42,31);
    cout <<"Date Graduated: " <<collgrad <<endl <<"   Course: " <<course <<endl;
    cout <<" Special Skills: " <<specskill;
    gotoxy(42,33);
    cout <<"Others: " <<others <<endl <<endl <<endl <<"EMPLOYMENT RECORD: (From present work backward)" <<endl <<endl;
    cout <<"    FROM";
    gotoxy(18,38);
    cout <<"TO";
    gotoxy(36,38);
    cout <<"POSITION";
    gotoxy(58,38);
    cout <<"COMPANY" <<endl;
    cout <<from;
    gotoxy(16,39);
    cout <<to;
    gotoxy(32,39);
    cout <<pastpos;
    gotoxy(56,39);
    cout <<company <<endl <<endl;
    cout <<"JOB DESCRIPTION/DUTIES AND RESPONSIBILITIES:" <<endl <<endl;
    cout <<jobdesc <<endl <<endl <<endl;
    cout <<"CHARACTER REFERENCES  " <<"(Not related to you)" <<endl;
    cout <<"       Name" 
    <<"                " <<"Occupation" 
    <<"            " <<"Address" <<endl;
    cout <<"1. " <<refname1 
    <<"             " 
    <<refoccu1 
    <<"                " <<refaddress1 <<endl; 



    gotoxy(22,2);
    getline (cin, position);
    gotoxy(10,3);
    getline (cin, name);
    gotoxy(18,4);
    getline (cin, city_address);
    gotoxy(17,5);
    getline(cin, tel_number);

    gotoxy(24,6);
    getline (cin, provincial_address);
    gotoxy(19,7);
    getline (cin, birthdate);
    gotoxy(49,7);
    getline (cin, birthplace);
    gotoxy(18,8);
    getline (cin, civil_status);
    gotoxy(55,8);
    getline (cin, citizenship);
    gotoxy(12,9);
    getline (cin, height);
    gotoxy(50,9);
    getline (cin, weight);
    gotoxy(14,10);
    getline (cin, religion);
    gotoxy(50,10);
    getline (cin, sex);
    gotoxy(29,11);
    getline (cin, husbandorwifename);
    gotoxy(24,12);
    getline (cin, occu_spouse);
    gotoxy(51,12);
    getline (cin, spouse_address);
    gotoxy(24,13);
    getline (cin, children_number);
    gotoxy(5,15);
    getline (cin, name_birthdateofchildren);
    gotoxy(19,16);
    getline (cin, fathername);
    gotoxy(54,16);
    getline (cin, fatheroccu);
    gotoxy(19,17);
    getline (cin, mothername);
    gotoxy(54,17);
    getline (cin, motheroccu);
    gotoxy(19,18);
    getline (cin, parentaddress);
    gotoxy(17,19);
    getline (cin, parentnumber);
    gotoxy(50,20);
    getline (cin, language);
    gotoxy(49,21);
    getline (cin, emergencycontact);
    gotoxy(21,22);
    getline (cin, emeraddress);
    gotoxy(17,23);
    getline (cin, emernumber);
    gotoxy(20,28);
    getline (cin, elemschool);
    gotoxy(58,28);
    getline (cin, elemgraduate);
    gotoxy(14,29);
    getline (cin, highschool);
    gotoxy(58,29);
    getline (cin, hsgraduate);
    gotoxy(13,30);
    getline (cin, vocational);
    gotoxy(58,30);
    getline (cin, vocgrad);
    gotoxy(10,31);
    getline (cin, college);
    gotoxy(58,31);
    getline (cin, collgrad);
    gotoxy(11,32);
    getline (cin, course);
    gotoxy(17,33);
    getline (cin, specskill);
    gotoxy(50,33);
    getline (cin, others);
    gotoxy(1,39);
    getline (cin, from);
    gotoxy(16,39);
    getline (cin, to);
    gotoxy(32,39);
    getline (cin, pastpos);
    gotoxy(56,39);
    getline (cin, company);
    gotoxy(10,42);
    getline (cin, jobdesc);
    gotoxy(3,48);
    getline (cin, refname1);
    gotoxy(23,48);
    getline (cin, refoccu1);
    gotoxy(45,48);
    getline (cin, refaddress1);

    
    cout <<endl <<endl <<endl;
    
    system("PAUSE")
    ;
    return EXIT_SUCCESS;
}



Any help is really appreciated. I wanted to discover the answer myself but it seems I am not that capable of coming up with the answer as my professor doesn't really teach us. He lets us discover everything ourselves and let us use the internet as guide.

Thanks in advance. :D
One way is to check the tel_number string for invalid characters. Just iterate over each character and exit if you find one.
Thanks for your answer man!. :D


After researching alot. Used this code instead.. Pretty simple and manages to do what I need.

1
2
3
4
5
6
7
8
9
    
if (isdigit(str[0]))
    {
    gotoxy(24,6);
}
    else
    {
        return EXIT_SUCCESS;
        }


Well, what you have displayed only checks the first digit. You will need a loop to get them all.
Topic archived. No new replies allowed.