//The variables for the 5 athletes salaries
double salary1, salary2, salary3, salary4, salary5;
//The variables for the 5 athletes Endorsements
double Endorsement1, Endorsement2, Endorsement3, Endorsement4, Endorsement5;
//store the total of the salaries
float totalSalary;
//store the average of the salaries
double avgSalary;
//store the total amount of endorsement
double totalEndorsement;
//store the average amount
double avgEndorsement;
//store the overall cash amount
double totalOverAll;
inFile >> salary1 >> salary2 >> salary3 >> salary4 >> salary5;
inFile >> Endorsement1 >> Endorsement2 >> Endorsement3 >> Endorsement4 >> Endorsement5;
outFile <<
//add up all the salaries
totalSalary = (salary1 + salary2 + salary3 + salary4 + salary5);
//average the salaries
avgSalary = (totalSalary / 5);
//add up all the endorsements
totalEndorsement = (Endorsement1 + Endorsement2 + Endorsement3 + Endorsement4 + Endorsement5);
//average the Endorsements
avgEndorsement = (totalEndorsement / 5);
//add up totalSalaries and totalEndorsement
totalOverAll = totalSalary + totalEndorsement;
cout << "................................................................\n" << endl;
cout << "ITCS 2530 - Programming Assigmnet for week #2\n" << endl;
cout << "................................................................\n" << endl;
cout << "Of the top 5 highest paid atheletes...\n" << endl;
cout << left << "Total of all salaries: "
<< right << totalSalary << endl;
cout << left << "Average of all salaries: "
<< right << avgSalary << endl;
cout << "\n" << endl;
cout << left << "Total of all Endorsements: "
<< right << totalEndorsement << endl;
cout << left << "Average of all Endorsements: "
<< right << avgEndorsement << endl;
cout << left << "The total of all salries and all endorsements! "
<< right << totalOverAll << endl;
outFile <<
//add up all the salaries
totalSalary = (salary1 + salary2 + salary3 + salary4 + salary5);
After removing outFile << or changing this code to:
1 2 3
//add up all the salaries
totalSalary = (salary1 + salary2 + salary3 + salary4 + salary5);
outFile << totalSalary;
fixed the error and compiled for me. The error the led me to this was:
main.cpp:44:15: error: no viable overloaded '='
totalSalary = (salary1 + salary2 + salary3 + salary4 + salary5);
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/ostream.tcc:359:25: note: candidate function
(the implicit copy assignment operator) not viable: no known conversion from 'double' to 'const std::basic_ostream<char>' for 1st
argument
extern template class basic_ostream<char>;
//The variables for the 5 athletes salaries
double salary1, salary2, salary3, salary4, salary5;
//The variables for the 5 athletes Endorsements
double endorsement1, endorsement2, endorsement3, endorsement4, endorsement5;
//store the total of the salaries
float totalSalary;
//store the average of the salaries
double avgSalary;
//store the total amount of endorsement
double totalEndorsement;
//store the average amount
double avgEndorsement;
//store the overall cash amount
double totalOverAll;
inFile >> salary1 >> salary2 >> salary3 >> salary4 >> salary5;
inFile >> endorsement1 >> endorsement2 >> endorsement3 >> endorsement4 >> endorsement5;
outFile <<
//add up all the salaries
totalSalary<< (salary1 + salary2 + salary3 + salary4 + salary5);
//average the salaries
avgSalary = (totalSalary / 5);
//add up all the endorsements
totalEndorsement = (endorsement1 + endorsement2 + endorsement3 + endorsement4 + endorsement5);
//average the endorsements
avgEndorsement = (totalEndorsement / 5);
//add up totalSalaries and totalEndorsement
totalOverAll = totalSalary + totalEndorsement;
cout << ".............................................\n" << end1;
cout << "ITCS2350 - 5 Highest Paid Athletes for week #2\n" << end1;
cout << ".............................................\n" << end1;
cout << "Of the top 5 highest paid athletes......\n" << end1;
cout << left << "Total of all salaries:"
<< right << totalSalary << end1;
cout << left << "Average of all salaries: "
<< right << avgSalary << end1;
cout << "\n" << end1;
cout << left << "Total of all Endorsements:"
<< right << totalEndorsement << end1;
cout << left << "Average of all Endorsements:"
<< right << avgEndorsement << end1;
cout << left << "The total of all salaries and all endorsements:"
<< right << totalOverAll << end1;
Since you haven't posted using code tags, we can't tell easily which line is line 44.
Also, is there any reason you're choosing not to tell us what the error is? Are you under the mistaken impression that withholding information from us makes it more fun?
warning: variable 'totalSalary' is uninitialized when used here
totalSalary<< (salary1 + salary2 + salary3 + salary4 + salary5);
^~~~~~~~~~~
note: initialize the variable 'totalSalary' to silence this warning
float totalSalary;
^
= 0.0
As it says, you can simply replace float totalSalary; with float totalSalary = 0.0; to initilise a float.