C++ int main error while compiling and two different errors.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dhruvc88
    New Member
    • Sep 2014
    • 6

    C++ int main error while compiling and two different errors.

    I am new to C++ and I am suppose to write a program in which the pc takes 5 values from a file called Values.in.txt and prints out

    Assessed Value.......... ............... XXXXXX.XX
    Total Taxable Amount @33% Assessed Value.....XXXXX X.XX
    Average Taxable Amount......... ..............X XXXXX.XX
    Tax Rate for each $100.00........ ............... ..3.07
    Total Property Tax:

    After I compile it I get this error

    sampletest.cpp: In function âint main()â:
    sampletest.cpp: 42: error: âhomevalueâ was not declared in this scope
    sampletest.cpp: 42: error: expected â;â before numeric constant

    My Code is as follows

    Code:
    #include <iostream>
    #include <fstream>
    #include <iomanip>
    #include <string> 
    
    using namespace std;
    
    int main()
    {
    	
    	ifstream inFile;
            ofstream outFile; 
    	double homevalue1, homevalue2, homevalue3, homevalue4, homevalue5;
    	double assessedvalue;
    	double taxableamount;
    	double avgtaxamt;
    	double taxrate;
    	double propertytax;
    
    	inFile.open ("Values.in.txt");
    	outFile.open ( "Values.out");
    
    	outFile << fixed << showpoint;
            outFile << setprecision(2); 
    
    	cout << "Calculating Data" << endl;
    
    	inFile >> homevalue1 >> homevalue2 >> homevalue3
    	       >> homevalue4 >> homevalue5;
    
    
    
    	homevalue1 = 125.0;
    	homevalue2 = 130.0;
    	homevalue3 = 135.0;
    	homevalue4 = 140.0;
    	homevalue5 = 145.0;
    
    
    
    	assessedvalue = homevalue1 + homevalue2 + homevalue3 + homevalue4 + homevalue 5;
    
    	taxableamount = assessedvalue / 3;
    	
    	avgtaxamt = taxableamount / 5;
    
    	taxrate = 3.07;
    
    	propertytax = taxableamount * taxrate / 100;
    	
    	
    
    	outFile << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"
                    << "-*-*-*-*-*-*-*-*-*-*-*-*-*" << endl;
    
    
    	outFile << setfill('.') << left << setw(35) << "Total Assessed Value: " 
                    << right << " " << assessedvalue << endl;
    
    
    	outFile << left << setw(35) << "Total Taxable Amount @33% Assessed Value: "	
    		<< setfill(' ') << right << setw(10) << taxableamount << endl;
    
    	outFile << setfill('.') << left << setw(35) << "Average Taxable Amount: "
    		<< setfill(' ') << right << avgtaxamt << endl;				// Add setw(8)
    
    
    	outFile << setfill('.') << left << setw(35) << "Tax rate for each 100 dollars: "
    		<< setfill(' ') << right << setw(9) << taxrate << endl;
    
    
    	outFile << setfill('.') << left << setw(35) << "Total Property Tax: "
    		<< setfill(' ') << right << propertytax << endl;
    
    
    		inFile.close(); 
                    outFile.close();
    
    
    
    	return 0;
    
    
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There's this:

    Code:
    assessedvalue = homevalue1 + homevalue2 + homevalue3 + homevalue4 + [B]homevalue[/B] 5;
    The compiler thinks homevalue is the variable and the 5 s a syntax error. Remove the space.

    Comment

    • dhruvc88
      New Member
      • Sep 2014
      • 6

      #3
      Ok besides the space what do I have to do? I declared homevalue1-4

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        What do you mean?

        Did making that change allow your code to compile?

        Comment

        • dhruvc88
          New Member
          • Sep 2014
          • 6

          #5
          Nevermind yes it did thank you!!

          Comment

          Working...