A company\'s performance is judged based on their earnings for every quarter of
ID: 3889090 • Letter: A
Question
A company's performance is judged based on their earnings for every quarter of the year. Create a C++ n called Earnings.cpp: Ask the user for the starting year (Input validation: do not accept a number less than 2000 or greater than 2017). e Ask the user for the final year (Input validation: do not accept a number less than 2000 or greater than 2017). For each of the years, ask the user to enter the earnings for each quarter (Q1Q2, Q3, and Q4) in US Dollars. Earnings for a quarter may be negative, meaning the company lost money in that quarter Earnings only need to be in integers. At the end, calculate the total carnings during the years, making sure to use proper units (S) and precision. A sample run of the program is shown below. . Enter the starting year: 2014 Enter the ending year: 2016 Enter the earnings for 2014 Q1 $123000 Enter the earnings for 2014 Q2: $65000 Enter the earnings for 2014 Q3: $-9000 Enter the earnings for 2014 Q4 $11000 Enter the earnings for 2015 Q1: $-10000 Enter the earnings for 2015 Q2: $40000 Enter the earnings for 2015 Q3 $120000 Enter the eanings for 2015 Q4 $125000 Enter the earnings for 2016 Q1: $80000 Enter the eanings for 2016 Q2: $90000 Enter the earnings for 2016 Q3: $10000 Enter the earnings for 2016 Q4: $100000 The total earnings during years 2014-2016 was $745000Explanation / Answer
//Please see the code and output below please do thumbs up if you like the solution
#include <iostream>
using namespace std;
int main()
{
int startYear;
int endYear;
int diff;
int loopValue;
int year;
double qEarning=0;
double tEarning=0;
cout<<"Enter the starting year: ";
cin>>startYear;
cout<<endl;
cout<<"Enter the ending year: ";
cin>>endYear;
cout<<endl;
diff =endYear-startYear+1;
year=startYear;
while(diff)
{
cout<<"Enter the earnings for "<<year<<" Q1: $";
cin>>qEarning;
tEarning+=qEarning;
cout<<"Enter the earnings for "<<year<<" Q2: $";
cin>>qEarning;
tEarning+=qEarning;
cout<<"Enter the earnings for "<<year<<" Q3: $" ;
cin>>qEarning;
tEarning+=qEarning;
cout<<"Enter the earnings for "<<year<<" Q4: $";
cin>>qEarning;
tEarning+=qEarning;
diff--;
year++;
}
cout<<"The total earnings during years "<<startYear<<"-"<<endYear<<" was $"<<tEarning;
return 0;
}
OUTPUT:
Enter the starting year: 2014
Enter the ending year: 2016
Enter the earnings for 2014 Q1: $123000
Enter the earnings for 2014 Q2: $65000
Enter the earnings for 2014 Q3: $-9000
Enter the earnings for 2014 Q4: $11000
Enter the earnings for 2015 Q1: $-10000
Enter the earnings for 2015 Q2: $40000
Enter the earnings for 2015 Q3: $120000
Enter the earnings for 2015 Q4: $125000
Enter the earnings for 2016 Q1: $80000
Enter the earnings for 2016 Q2: $90000
Enter the earnings for 2016 Q3: $10000
Enter the earnings for 2016 Q4: $100000
The total earnings during years 2014-2016 was $745000
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.