im still pretty new to c++ and for this program, i use loops, but i don't think i wrote them correctly. i keep running into errors. i really don't understand what they mean, so if someone can help me comprehend, i would really appreciate it!
my program and the errors:
CODE
//This assignment5.cpp program is designed to read from an input file
// and compute the costs for the Green Tree Service Company. The input
//file include data that represents a series of jobs that the company
//has performed. Using the data values, it will compute the amount
//of each job. It will list each job as a character with integers and
//float values if applicable. It will also generate a statement that
//lists each job and the job number. it will also include the following
//computed amounts: tree planting, tree removal, tree trimming, stump
//removal, total billed and the total amount due.
//Input: the input will be read from a data file. No input will be
//entered by the user.
//Output: the output will display a nicely formatted statement that
//displays the amounts two decimal points to the right, and will be
//right-justified. The amounts displayed will be: tree planting,tree
//removal, trimming, stump removal, total billed, and the TOTAL.
#include <iostream>
#include <iomanip>
using namespace std;
const float SMALLTREE = 35.00; // cost of planting small tree
const float MEDTREE = 100.00; // cost of planting medium tree
const float LARGETREE = 500.00; // cost of planting large tree
const float TREEREMOVAL = 500.00; // cost of tree removal
const float HRTRIMMING = 75.00; // cost of trimming per hour
const float STUMPREM1 = 75.00; // cost of removing stump diameter < 10 inches
const float STUMPREM2 = 10.00; // cost of removing stump diameter > 10 inches
int main()
{
int num;
int numoftrees;
int numoftrees2;
int largetreeamt;
int numremove;
int diameter1;
int diameter2;
int jobnum;
int counter;
float trimhrs;
float smalltreeamt;
float medtreeamt;
float trimminghrs;
float removalamt1;
float removalamt2;
float TOTAL;
cout << fixed << showpoint << setprecision(2);
{
int numoftrees1;
cin >> numoftrees1;
for ( int i=0; i < numoftrees1; i++)
{
smalltreeamt = 0;
for (int j=0; j<numoftrees1; j++)
{
cin >> numoftrees1;
smalltreeamt = SMALLTREE * numoftrees1;
}
cout << smalltreeamt << endl;
}
{
int numoftrees2;
cin >> numoftrees2;
for (int i=0; i < numoftrees2; i++)
{
medtreeamt = 0;
for (int j=0; j<num; j++)
{
cin >> numoftrees2;
medtreeamt = MEDTREE * numoftrees2;
}
cout << medtreeamt << endl;
}
{
int numoftrees3;
cin >> numoftrees3;
for ( int i = 0; i < numoftrees3; i++)
{
largetreeamt = 0;
for (float j=0; j<num; j++)
{
cin >> numoftrees3;
largetreeamt = SMALLTREE * numoftrees3;
}
cout << largetreeamt << endl;
}
{
float removalamt;
int numremove;
cin >> removalamt;
for (int i = 0; i < numremove; i++)
{
cin >> numremove;
removalamt = TREEREMOVAL * numremove;
}
cout << removalamt << endl;
}
{
int sum = 0;
float trimhours;
int count;
cin >> trimhours;
for ( int i = 0; i < count; i++)
{
cin >> trimhours;
trimminghrs = HRTRIMMING * trimhours;
}
cout << trimminghrs << endl;
}
int diameter1;
cin >> diameter1;
for ( int i = 0; i < diameter1; i++)
{
if (diameter1 <= 10)
{
cin >> diameter1;
removalamt1 = STUMPREM1 * diameter1;
}
else (diameter2 > 10);
{
cin >> diameter2;
removalamt2 = STUMPREM2 * diameter2;
}
}
cin >> jobnum;
int cnt = 0, sum = 0, data;
float smalltreeamt;
float medtreeamt;
float largetreeamt;
float removalamt;
float trimminghrs;
float removalamt1;
float removalamt2;
float TOTAL;
cin >> data;
while (!cin.eof())
{
TOTAL = smalltreeamt + medtreeamt + largetreeamt +
removalamt + trimminghrs + removalamt1 + removalamt2;
cout << TOTAL << endl;
}
{
cin >> jobnum;
cout << setw(23) << setfill(' ') << setw(20) << left << "Tree"
<< setw(20) << setfill(' ') << left << setw(11)
<< "Stump" << setw(7) << "Total" << endl;
cout << left << setw(8) << "Job #" << left << setw(14) << "Planting"
<< left << setw(11) << "Trimming" << left << setw(11)
<< "Removal" << left << setw(8) << "Billed" << endl;
cout << left << setw(8) << jobnum << "$" << setw(9) << right
<< numoftrees << setw(3) << "$" << setw(9) << right
<< removalamt << setw(3) << "$" << setw(9) << right
<< trimminghrs << setw(3) << "$" << setw(9) << right
<< removalamt1 || removalamt2 << setw(3) << right << TOTAL
<< endl;
cout << setw(57) << "TOTAL" << "$" << setw(9) << TOTAL <<endl;
return 0;
}}}}
}
and these are the errors i get:
assignment5.cpp: In function âint main()â:
assignment5.cpp:69: error: name lookup of âiâ changed for new ISO âforâ scoping
assignment5.cpp:55: error: using obsolete binding at âiâ
assignment5.cpp:90: warning: converting to âintâ from âfloatâ
assignment5.cpp:172: error: no match for âoperator<<â in âremovalamt2 << std::setw(3)â
again, thanks for anyone who can explain/kind of help me
This post has been edited by tatertot560: 14 Mar, 2008 - 07:55 AM