six functions only

Good morning all,

This assignment is to write six functions only. Our professor will be writing the main function to test.

I understand that the fatal error LNK1120 is because there is no main function, but I am not understanding the other two errors,C4530 and LNK2019.

ge6wd2.cpp
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.

/out:ge6wd2.exe
ge6wd2.obj
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main reference
d in function ___tmainCRTStartup
ge6wd2.exe : fatal error LNK1120: 1 unresolved externals


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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
// Function 1 Takes a lower case character and makes uppercase
// Function 2 How often a character is shown in an array of characters
// Function 3 Creates five random numbers and puts it in an array
// Function 4 Taking a string and seeing how many vowels and constants are in the array
// Function 5 Takes three known variables and creates a monthly payment
// Function 6 Validates input and displays information in calendar form

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <cmath>

using namespace std;


void toUpper(char string[])

{
     int x=0;

     int y=0;

     int z=65;

     while (string[x] != '\0')

     {
           if(string[x] >= 97 && string[x] <= 122)

           {
                        for(y=97; y<=122; y++)

                        {
                                  if(string[x]==(char)y)

                                  {
                                                        string[x] = (char)z;

                                  }

                                  z++;
                        }

                        z=65;
           }

           x++;
     }

}
 
 void getCharacterFrequency(char inputString[], unsigned int frequency[])

{
      int x =0;

      int y =0;

      int z =0;

      int size = 26;

      for(x=0; x<size; x++)

      {

               frequency[x] =0;

      }
      
      x=0;
      
      while (inputString[x] != '\0')

      {
            if(inputString[x] >= 65 && inputString[x] <= 90)

            {
                       for(y=65; y<=90; y++)

                       {
                                 if(inputString[x]==(char)y)

                                 {
                                                            frequency[z]=frequency[z]+1;

                                 }

                                 z++;
                       }      
            }
            
            if(inputString[x] >= 97 && inputString[x] <= 122)

            {
                              for(y=97; y<=122; y++)

                       {
                                 if(inputString[x]==(char)y)

                                 {
                                                            frequency[z]=frequency[z]+1;

                                 }

                                 z++;
                       }      
                              
            }
            
            x++;

            z=0;
      }
}

void generateLotteryNumbers(int lotteryNumbers[])

{
     int size =6;

     for(int x =0; x<size; x++)

     {

             lotteryNumbers[x] = 1+rand()%49;

     }
}

void analyzeString(char inputString[], int& numVowels, int& numConsonants, int& numSeperators)

{
     int x=0;
     
     while(inputString[x] != '\0')

     {
		 if((inputString[x]>=65 && inputString[x]<=90) || (inputString[x]>=97 && inputString[x]<=122))

                          {
                                                 if(inputString[x] == 'a' || inputString[x] == 'e' || inputString[x] == 'i' || inputString[x] == 'o' || inputString[x] == 'u' || inputString[x] == 'A' || inputString[x] == 'E' || inputString[x] == 'I' || inputString[x] == 'O' || inputString[x] == 'U')

                                                 {
                                                                   numVowels++;

                                                 }
                                                 
                                                 else

                                                 {
                                                     numConsonants++;

                                                 }
                          }
                          
                          else

                          {
                              numSeperators++;

                          }
     }
}

double calculateMonthlyPayment(double loan, double rate, int year)

{
       double term=0;

       const int MONTHS = 12;

       double payment=0;
       

       if((loan >= 1000 && loan<= 1000000) && (rate >=2 && rate<= 20) && (year >=5 && year <=30))

       {
                term = pow((1 + rate / MONTHS), MONTHS * year);
                payment = (loan * rate / MONTHS * term) / (term - 1.0);
                 cout << fixed << showpoint << setprecision(2);
                 cout << "Monthly payment: $" << payment << endl;
                return payment;

       }

       else

       {
           return -1.0;
       }
}

void displayCalenderDays(int StartDay, int DayMonth)

{
     int x=0;

     int y=0;
     
     if((StartDay >=0 && StartDay<=6) && (DayMonth >= 1 && DayMonth <=31))

     {
                  if(StartDay !=0)

                  {
                              for(x=0; x<StartDay; x++)

                              {
                                       cout<<(char)32;
                              }
                              
                  }
                  
                  for(y=1; y<=DayMonth; y++)

                  {
                           for(x=StartDay; x<=6; x++)

                           {
                                           cout<<y;

                                           y++;
                           }

                           cout<<endl;
                  }
     }

     else

     {
         cout<<"These numbers are incorrect.  Please try again."<<endl;
     }
}


Thank you in advance for any insight that can be given.

Debra
Last edited on
Your best bet is to add a main function in to test it and compile it and see what errors you get. How do you know your functions work without being able to test them? I'd suggest putting a function call to each function and display the results so that you know your functions are working properly. I'd also try different things.

Like your toupper function, I'd pass strings with spaces, uppercase, lowercase, numbers, and other characters just to make sure it only affects the letters that you meant for it to change.

There is also some things I saw in your functions that either aren't needed, make your functions a lot harder to understand, and may not work as intended.
Topic archived. No new replies allowed.