I'm having trouble figuring out why my code is giving me an error. Can anyone help?
Code:#include<iostream> #include<fstream> #include<iomanip> #include<string> using namespace std; int main () { string name, month, day, yr, loanAmount; string currentDateMonths, currentDateDays,currentDateYears; string totaldays; ifstream infile; infile.open("data3.txt", ifstream::in); infile >> currentDateMonths >> currentDateDays >> currentDateYears; while ( ! infile.eof ()) { infile >> name >> month >> day >> yr >> loanAmount; cout << name << month << day << yr << loanAmount; } infile.close(); return 0; } //Loan Length int loanTime () { int month, day; int currentDateMonths, currentDateDays, totaldays; if (month == currentDateMonths) totaldays = (currentDateDays - day); else if (month == (currentDateDays - day)) case (month == 1 || 3 || 5 || 7 || 8 || 10 || 12): totaldays = (31 - day) + currentDateDays; case totaldays = (28 - day) + currentDateDays: else if (month == currentDateMonths - 2) case (month == 1 || 2): totaldays = (59 - day) + currentDateDays; else if (month > currentDateMonths) case (month == 11): totaldays = (61 - day) + currentDateDays; case (month == 12): if (currentDateMonths == 1) totaldays = (31 - day) + currentDateDays; else if (currentDateMonths == 2) totaldays = (62 - day) + currentDateDays; else if (month < currentDateMonths) case (month == 11 && currentDateMonths == 1): totaldays = (61 - day) + currentDateDays; case (month == 11 && currentDateMonths >= 2): totaldays = 60; case (month == 12 && currentDateMonths == 1): totaldays = (31 - day) + currentDateDays; case (month == 12 && currentDateMonths == 2): totaldays = (62 - day) + currentDateDays; case (month == 12 && currentDateMonths > 2): totaldays = (60 - day) + currentDateDays; return totaldays; }
1>------ Build started: Project: Project 3, Configuration: Debug Win32 ------
1>Compiling...
1>Project 3.cpp
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(45) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(47) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(48) : error C2181: illegal else without matching if
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(49) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(52) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(54) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(60) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(62) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(64) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(66) : error C2046: illegal case
1>c:\users\pat\documents\visual studio 2008\projects\project 3\project 3\project 3.cpp(68) : error C2046: illegal case
1>Build log was saved at "file://c:\Users\Pat\Documents\Visual Studio 2008\Projects\Project 3\Project 3\Debug\BuildLog.htm"
1>Project 3 - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If you can help me, I'd greatly appreciate it. Thanks!
-yusko63



LinkBack URL
About LinkBacks


