Correct the code without making any changes to main() below (including adding co
ID: 3799618 • Letter: C
Question
Correct the code without making any changes to main() below (including adding correct Pre and Post to function calcNewWages() )so that when 1300 is entered for the current earnings the output will be:
Enter current salary: 1300
Current: 1300.00
Raise: 27.30
New Amount: 1327.30
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <iostream>
#include <iomanip>
/*This application will apply
cost of living to your current salary
*/
using namespace std;
#define COLA 2.1
double calcNewWages(double, double);
int main()
{
//Declare Variables
double currentSalary, newSalary, raise;
cout << "Enter current salary: ";
cin >> currentSalary;
//Calculate amount of raise and
raise = calcNewWages(currentSalary, newSalary);
//Output current an new
cout << setprecision(2) << fixed <<endl << endl;
cout << "Current: " << setw(10)<< currentSalary << endl;
cout << "Raise: " << setw(10)<< raise << endl;
cout << "New Amount: " << setw(10)<< newSalary << endl;
return 0;
}
double calcNewWages(double thisYear, double nextYear)
{
//Pre - you fill in
//Post: You fill in
//Purpose: This function calcuates how mush you will earn when COLA is applied
double amount;
amount = thisYear * COLA/100.0;
nextYear = thisYear + amount;
return amount;
}
1488786900 03/05/2017 11:55pm
Text Entry
Keyboard ShortcutsHTML Editor Rich Content Editor
CancelUpdate Description
Additional Comments:
CancelUpdate Comments
Additional Comments:
Rubric
Can't change a rubric once you've started using it.
Find a Rubric
Title
You've already rated students with this rubric. Any major changes could affect their assessment results.
Title
I'll write free-form comments when assessing students
Use this rubric for assignment grading
Hide score total for assessment results
CancelCreate Rubric
Previous
Copy and paste or type your submission right here.Keyboard ShortcutsHTML Editor Rich Content Editor
CancelSubmit AssignmentExplanation / Answer
Hi
I have modified the code and highlighted the code changes below.
#include <iostream>
#include <iomanip>
/*This application will apply
cost of living to your current salary
*/
using namespace std;
#define COLA 2.1
double calcNewWages(double, double &) ;
int main()
{
//Declare Variables
double currentSalary, newSalary, raise;
cout << "Enter current salary: ";
cin >> currentSalary;
//Calculate amount of raise and
raise = calcNewWages(currentSalary, newSalary);
//Output current an new
cout << setprecision(2) << fixed <<endl << endl;
cout << "Current: " << setw(10)<< currentSalary << endl;
cout << "Raise: " << setw(10)<< raise << endl;
cout << "New Amount: " << setw(10)<< newSalary << endl;
return 0;
}
double calcNewWages(double thisYear, double &nextYear)
{
//Pre - you fill in
//Post: You fill in
//Purpose: This function calcuates how mush you will earn when COLA is applied
double amount;
amount = thisYear * COLA/100.0;
nextYear = thisYear + amount;
return amount;
}
Output:
sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
Enter current salary: 1300
Current: 1300.00
Raise: 27.30
New Amount: 1327.30