Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- //input months
- double m;
- cout << "Enter number of months: ";
- cin >> m;
- //starting payment is 1
- double s;
- s = 1;
- //input grant, grant is equal to 1
- double g;
- g = s;
- //calculate month 1 if input is 1
- if (m == 1)
- {
- cout << "Month " << 1 << ": $" << g << endl;
- system("PAUSE");
- return 0;
- }
- //calculate month 2 if input is 2
- else if (m == 2)
- {
- cout << "Month " << 1 << ": $" << g << endl;
- g = s + 1;
- cout << "Month " << 2 << ": $" << g << endl;
- system("PAUSE");
- return 0;
- }
- //calculate month 1 and 2, loop months 3 - 12
- else
- {
- cout << "Month " << 1 << ": $" << g << endl;
- g = s + 1;
- cout << "Month " << 2 << ": $" << g << endl;
- (m <= 12);
- s = g;
- for (double i = 3; i <= m; i++)
- {
- g = s * 3;
- cout << "Month " << i << ": $" << g << endl;
- s = g;
- if (m == i)
- {
- break;
- }
- i = i + 1;
- g = s * 2;
- cout << "Month " << i << ": $" << g << endl;
- if (m == i)
- {
- break;
- }
- s = g;
- i = i;
- }
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement