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
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;
}
Comment