Thread: Build error

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    4

    Build error

    When I build this program, I get an error message; not from Visual Studio, but from my computer. Can anyone help me?

    Code:
    #include<iostream>
    #include<fstream>
    #include<iomanip>
    #include<string>
    
    
    using namespace std;
    
    int main ()
    {
    	int interest1, interest2, interest3; 
    	string name1, name2, name3;
    	int month1, day1, yr1, loanAmount1;
    	int month2, day2, yr2, loanAmount2;
    	int month3, day3, yr3, loanAmount3;
    	string currentDateMonths, currentDateDays,currentDateYears;
    	string fileMonth, fileDays, fileYears;
    	int totaldays1, totaldays2, totaldays3;
    	ifstream infile; 
    	infile.open("data3.txt", ifstream::in);
    	ofstream outfile1, outfile2, outfile3; 
    	outfile1.open("Michael.txt", ofstream::out);
    	outfile2.open("Sonny.txt", ofstream::out);
    	outfile3.open("Don.txt", ofstream::out);
    
    	infile >> currentDateMonths >> currentDateDays >> currentDateYears;
    	infile >> name1 >> month1 >> day1 >> yr1 >> loanAmount1;
    	infile >> name2 >> month2 >> day2 >> yr2 >> loanAmount2; 
    	infile >> name3 >> month3 >> day3 >> yr3 >> loanAmount3;
    	cout << "Please enter the date you wish to calculate interest with in the Month - Day - Year format: " << endl; 
    	cin >> currentDateMonths >> currentDateDays >> currentDateYears; 
    	while (totaldays1 < 29)
    	{
    		outfile1 << name1 << '\t' << (loanAmount1 + interest1) << '\t' << (28 - totaldays1) << endl;
    	}
    	
    
    	infile.close();
    	
    	
    	
    	return 0;
    }
    
    
    //Loan Length
    
    int loanTime1 ()
    {
    	int month1, day1;
    	int currentDateMonths, currentDateDays, totaldays1;
    	if (month1 = currentDateMonths)
    	{
    		totaldays1 = (currentDateDays - day1);
    	}
    	if (month1 = (currentDateDays - day1))
    	{
    		if(month1 = 1 || 3 || 5 || 7 || 8 || 10 || 12);
    		{
    			totaldays1 = (31 - day1) + currentDateDays;
    		}
    		}
    	if (month1 = currentDateMonths - 2)
    	{
    		if (month1 = 1 || 2);
    		{
    			totaldays1 = (59 - day1) + currentDateDays;
    		}
    	}
    	if (month1 > currentDateMonths)
    	{
    		if (month1 = 11);
    		{
    			totaldays1 = (61 - day1) + currentDateDays;
    		}
    		if (month1 = 12);
    		{
    			totaldays1 = (31 - day1) + currentDateDays;
    		}
    	}
    	if (currentDateMonths = 1)
    			totaldays1 = (31 - day1) + currentDateDays;
    	else if(currentDateMonths = 2)
    			totaldays1 = (62 - day1) + currentDateDays;
    	else (month1 < currentDateMonths);
    	if (month1 = 11 && currentDateMonths == 1);
    	{
    		totaldays1 = (61 - day1) + currentDateDays;
    	}
    	if (month1 = 11 && currentDateMonths >= 2);
    	{
    		totaldays1 = 60;
    	}
    	if (month1 = 12 && currentDateMonths == 1);
    	{
    		totaldays1 = (31 - day1) + currentDateDays;
    	}
    	if (month1 = 12 && currentDateMonths == 2);
    	{
    		totaldays1 = (62 - day1) + currentDateDays;
    	}
    	if (month1 = 12 && currentDateMonths > 2);
    	{
    		totaldays1 = (60 - day1) + currentDateDays;
    	}
    	return totaldays1;
    }
    
    
    
    
    
    int loanTime2 ()
    {
    	int month2, day2;
    	int currentDateMonths, currentDateDays, totaldays2;
    	if (month2 = currentDateMonths)
    	{
    		totaldays2 = (currentDateDays - day2);
    	}
    	if (month2 = (currentDateDays - day2))
    	{
    		if(month2 = 1 || 3 || 5 || 7 || 8 || 10 || 12);
    		{
    			totaldays2 = (31 - day2) + currentDateDays;
    		}
    		}
    	if (month2 = currentDateMonths - 2)
    	{
    		if (month2 = 1 || 2);
    		{
    			totaldays2 = (59 - day2) + currentDateDays;
    		}
    	}
    	if (month2 > currentDateMonths)
    	{
    		if (month2 = 11);
    		{
    			totaldays2 = (61 - day2) + currentDateDays;
    		}
    		if (month2 = 12);
    		{
    			totaldays2 = (31 - day2) + currentDateDays;
    		}
    	}
    	if (currentDateMonths = 1)
    			totaldays2 = (31 - day2) + currentDateDays;
    	else if(currentDateMonths = 2)
    			totaldays2 = (62 - day2) + currentDateDays;
    	else (month2 < currentDateMonths);
    	if (month2 = 11 && currentDateMonths == 1);
    	{
    		totaldays2 = (61 - day2) + currentDateDays;
    	}
    	if (month2 = 11 && currentDateMonths >= 2);
    	{
    		totaldays2 = 60;
    	}
    	if (month2 = 12 && currentDateMonths == 1);
    	{
    		totaldays2 = (31 - day2) + currentDateDays;
    	}
    	if (month2 = 12 && currentDateMonths == 2);
    	{
    		totaldays2 = (62 - day2) + currentDateDays;
    	}
    	if (month2 = 12 && currentDateMonths > 2);
    	{
    		totaldays2 = (60 - day2) + currentDateDays;
    	}
    	return totaldays2;
    }
    
    
    
    
    int loanTime3 ()
    {
    	int month3, day3;
    	int currentDateMonths, currentDateDays, totaldays3;
    	if (month3 = currentDateMonths)
    	{
    		totaldays3 = (currentDateDays - day3);
    	}
    	if (month3 = (currentDateDays - day3))
    	{
    		if(month3 = 1 || 3 || 5 || 7 || 8 || 10 || 12);
    		{
    			totaldays3 = (31 - day3) + currentDateDays;
    		}
    		}
    	if (month3 = currentDateMonths - 2)
    	{
    		if (month3 = 1 || 2);
    		{
    			totaldays3 = (59 - day3) + currentDateDays;
    		}
    	}
    	if (month3 > currentDateMonths)
    	{
    		if (month3 = 11);
    		{
    			totaldays3 = (61 - day3) + currentDateDays;
    		}
    		if (month3 = 12);
    		{
    			totaldays3 = (31 - day3) + currentDateDays;
    		}
    	}
    	if (currentDateMonths = 1)
    			totaldays3 = (31 - day3) + currentDateDays;
    	else if(currentDateMonths = 2)
    			totaldays3 = (62 - day3) + currentDateDays;
    	else (month3 < currentDateMonths);
    	if (month3 = 11 && currentDateMonths == 1);
    	{
    		totaldays3 = (61 - day3) + currentDateDays;
    	}
    	if (month3 = 11 && currentDateMonths >= 2);
    	{
    		totaldays3 = 60;
    	}
    	if (month3 = 12 && currentDateMonths == 1);
    	{
    		totaldays3 = (31 - day3) + currentDateDays;
    	}
    	if (month3 = 12 && currentDateMonths == 2);
    	{
    		totaldays3 = (62 - day3) + currentDateDays;
    	}
    	if (month3 = 12 && currentDateMonths > 2);
    	{
    		totaldays3 = (60 - day3) + currentDateDays;
    	}
    	return totaldays3;
    }
    
    
    //Loan 1 Interest
    
    int interest1 ()
    {
    	int interest1;
    	int totaldays1;
    	if (totaldays1 < 8);
    	{
    		interest1 = (totaldays1 * 200);
    	}
    	if (totaldays1 >= 8 && totaldays1< 15); 
    	{ 
    		interest1 = (1400 + ((totaldays1 - 7) * 400));
    	}
    	if (totaldays1 >= 15 && totaldays1 < 22); 
    	{
    		interest1 = (4200 + ((totaldays1 - 14) * 600)); 
    	}
    	if (totaldays1 >= 22 && totaldays1 < 29);
    	{ 
    		interest1 = (8400 + ((totaldays1 - 21) * 800)); 
    	}
    	if (totaldays1 >= 29); 
    	{
    		interest1 = (14000 + ((totaldays1 - 28) * 1000));
    	}
    
    	return interest1;
    }
    
    
    int interest2 ()
    {
    	int interest2, totaldays2;
    	if (totaldays2 < 8);
    	{
    		interest2 = (totaldays2 * 200);
    	}
    	if (totaldays2 >= 8 && totaldays2< 15); 
    	{ 
    		interest2 = (1400 + ((totaldays2 - 7) * 400));
    	}
    	if (totaldays2 >= 15 && totaldays2 < 22); 
    	{
    		interest2 = (4200 + ((totaldays2 - 14) * 600)); 
    	}
    	if (totaldays2 >= 22 && totaldays2 < 29);
    	{ 
    		interest2 = (8400 + ((totaldays2 - 21) * 800)); 
    	}
    	if (totaldays2 >= 29); 
    	{
    		interest2 = (14000 + ((totaldays2 - 28) * 1000));
    	}
    
    	return interest2;
    }
    
    
    
    int interest3 ()
    {
    	int interest3, totaldays3;
    	if (totaldays3 < 8);
    	{
    		interest3 = (totaldays3 * 200);
    	}
    	if (totaldays3 >= 8 && totaldays3 < 15); 
    	{ 
    		interest3 = (1400 + ((totaldays3 - 7) * 400));
    	}
    	if (totaldays3 >= 15 && totaldays3 < 22); 
    	{
    		interest3 = (4200 + ((totaldays3 - 14) * 600)); 
    	}
    	if (totaldays3 >= 22 && totaldays3 < 29);
    	{ 
    		interest3 = (8400 + ((totaldays3 - 21) * 800)); 
    	}
    	if (totaldays3 >= 29); 
    	{
    		interest3 = (14000 + ((totaldays3 - 28) * 1000));
    	}
    
    	return interest3;
    }


    Thanks,

    yusko63

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Code:
    while (totaldays1 < 29)
    	{
    		outfile1 << name1 << '\t' << (loanAmount1 + interest1) << '\t' << (28 - totaldays1) << endl;
    	}
    When do you expect this loop to stop?

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    4
    Oh, I get it now. But I wasn't trying to loop it, I'm trying to set a condition statement; how would I set that up?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You would probably have to assign a meaningful value to totaldays1. Then if you want to make a decision, you generally use if.

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    4
    I changed the code:

    Code:
    if (totaldays1 < 29)
    	{
    		int totaldays1;
    		outfile1 << name1 << '\t' << (loanAmount1 + interest1) << '\t' << (28 - totaldays1) << endl;
    	}
    but it still gives me the error

  6. #6
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    what is an error?

    also note that
    Code:
    if (month3 = 1 || 2);
    does not do what you expect (and your program full of it). it should be

    Code:
    if (month3 == 1 || month3 == 2)
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM