Ok its me again. Im getting really frustrated with my practice project... :s
I cant figure out what i have done wrong when adding the total of vectors. Also the compiler tells me that i have 2 warnings...
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
|
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int money;
char x;
int i=0;
int temp=0;
vector<int>moneysaved;
system("TITLE Savings account details");
while (true)
{
system("CLS");
cout << "Enter money you have put away:";
cin >> money;
moneysaved.push_back(money);
for (int i=0; i<moneysaved.size(); i++)
{
cout << moneysaved[i];
cout << '+';
}
cout << endl << endl << "Would you like to try again? (Y or N)";
cin >> x;
if (x=='n' || x=='N')
{
break;
}
}
system("CLS");
cout << "Total: ";
for (int y=0; y<=moneysaved.size(); y++)
{
temp += moneysaved[i];
}
cout << temp << endl;
system("pause");
return 0;
}
|
And this is what compiler says:
1>------ Build started: Project: Savings, Configuration: Debug Win32 ------
1>Compiling...
1>file.cpp
1>c:\users\mashikag\documents\visual studio 2008\projects\savings\savings\file.cpp(22) : warning C4018: '<' : signed/unsigned mismatch
1>c:\users\mashikag\documents\visual studio 2008\projects\savings\savings\file.cpp(41) : warning C4018: '<=' : signed/unsigned mismatch
1>Linking...
1>LINK : C:\Users\Mashikag\Documents\Visual Studio 2008\Projects\Savings\Debug\Savings.exe not found or not built by the last incremental link; performing full link
1>Embedding manifest...
1>Build log was saved at "file://c:\Users\Mashikag\Documents\Visual Studio 2008\Projects\Savings\Savings\Debug\BuildLog.htm"
1>Savings - 0 error(s), 2 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
:S