Someone please help:
This is the Q: (having trouble with finding total
A well-regarded manufacturer of widgets has been losing 4% of its sales each year.
The company’s annual profit is 10% of sales. This year, the company has had $10 million in
sales and a profit of $1 million. Determine the expected sales and profit for the next 10 years.
Your program should produce a display in the following form:
This program will calculate expected sales and a projected profit for 10 years of a company:
Year Expected Sales Projected Profit
---- -------------- ----------------
1 $10000000.00 $1000000.00
2 $ 9600000.00 $ 960000.00
3 $ 9216000.00 $ 921600.00
4 $ 8847360.00 $ 884736.00
5 $ 8493465.60 $ 849346.56
6 $ 8153726.98 $ 815372.70
7 $ 7827577.90 $ 782757.79
8 $ 7514474.78 $ 751447.48
9 $ 7213895.79 $ 721389.58
10 $ 6925339.96 $ 692534.00
--------------------------------------------
Total: $ 73791841.00 $ 0.00
I have achieved the above, except for the part where it asks for the Total for sales and profit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
cout << "\nThis program will calculate expected sales and a projected profit for 10 years of a company:\n\n";
int count = 1, year = 10;
double sales = 10000000, profit = 1000000, expsales, saleTotal = 0, profitTotal = 0;
cout << "Year Expected Sales Projected Profit \n";
cout << "---- -------------- ---------------- \n";
cout << setiosflags(ios::fixed)<<setprecision(2);
cout << count << setw(10) << "$" << sales << setw(10) << "$" << profit << endl;
for (count = 2; count <= year; count++)
{
expsales = 0.96*sales;
profit = 0.1*expsales;
sales = expsales;
saleTotal += expsales;
profitTotal = 0;
if (count == year)
cout << count << setw(10) << "$ " << expsales << setw(11) << "$ " << profit << endl;
else
cout << count << setw(11) << "$ " << expsales << setw(11) << "$ " << profit << endl;
}
cout << "--------------------------------------------\n";
cout << "Total:" << setw(6) << "$ " << saleTotal << setw(10) << "$ " << profitTotal << endl;
return 0;
}
|
All help is much appreciated!
*note: table might have lost its format.