|
|
Budgeted Spent Difference ================================================= Housing 580.00 1.00 -579.00 Utilities 150.00 1.00 -149.00 Household 65.00 1.00 -64.00 Transportation 50.00 1.00 -49.00 Food 250.00 1.00 -249.00 Medical 30.00 1.00 -29.00 Insurance 100.00 1.00 -99.00 Entertainment 150.00 1.00 -149.00 Clothing 75.00 1.00 -74.00 Miscellaneous 50.00 1.00 -49.00 ================================================= Total 1500.00 10.00 -1490.00 ================================================= Congratulations! You were $1490.00 under budget in ju 2022. |
setw sets the minimum width of the next thing that you output. If you use it before each thing that you output, and use the same width for the same position on each row, then you could think of it as the "column width".if(&Spent < &Budget) probably doesn't do what you want. The & operator gives you a pointer to the variable so what this if statement does is that it checks whether the object that Spent refers to is stored before the object that Budget refers to in memory. | jetm0t0 wrote: |
|---|
| Setw(); not outputting what I want with structures |
|
|
This program calculates n! and the sum of the integers up to n for values 1 to limit.
What upper limit for n would you like? 10
integer sum factorial
1 1 1
2 3 2
3 6 6
4 10 24
5 15 120
6 21 720
7 28 5040
8 36 40320
9 45 362880
10 55 3628800 |
|
|
|
|
|
|
|
|
|
|
|
|
*** BUDGET ****
Category Budget Expense Diff
=============================================
Housing 580.00 580.00 0.00
Utilities 150.00 130.00 -20.00
Household 65.00 50.00 -15.00
Transportation 50.00 50.00 0.00
Food 250.00 230.00 -20.00
Medical 30.00 30.00 0.00
Insurance 100.00 100.00 0.00
Entertainment 150.00 120.00 -30.00
Clothing 75.00 100.00 25.00
Miscellaneous 50.00 30.00 -20.00
=============================================
TOTALS 1500.00 1420.00 -80.00
Enter Housing amount $480
Enter Utilities amount $250
Enter Household amount $55
Enter Transportation amount $55
Enter Food amount $255
Enter Medical amount $34
Enter Insurance amount $107
Enter Entertainment amount $143
Enter Clothing amount $77
Enter Miscellaneous amount $64
Enter Housing amount $567
Enter Utilities amount $223
Enter Household amount $34
Enter Transportation amount $87
Enter Food amount $265
Enter Medical amount $99
Enter Insurance amount $102
Enter Entertainment amount $149
Enter Clothing amount $12
Enter Miscellaneous amount $67
*** BUDGET ****
Category Budget Expense Diff
=============================================
Housing 567.00 580.00 13.00
Utilities 223.00 130.00 -93.00
Household 34.00 50.00 16.00
Transportation 87.00 50.00 -37.00
Food 265.00 230.00 -35.00
Medical 99.00 30.00 -69.00
Insurance 102.00 100.00 -2.00
Entertainment 149.00 120.00 -29.00
Clothing 12.00 100.00 88.00
Miscellaneous 67.00 30.00 -37.00
=============================================
TOTALS 1605.00 1420.00 -185.00
Program ended with exit code: 0 |
int x{0}; is the same as int x = 0; |
|
*** BUDGET ****
Category Budget Expense Diff
=============================================
Housing 580.00 580.00 0.00
Utilities 150.00 130.00 -20.00
Household 65.00 50.00 -15.00
Transportation 50.00 50.00 0.00
Food 250.00 230.00 -20.00
Medical 30.00 30.00 0.00
Insurance 100.00 100.00 0.00
Entertainment 150.00 120.00 -30.00
Clothing 75.00 100.00 25.00
Miscellaneous 50.00 30.00 -20.00
=============================================
TOTALS 1500.00 1420.00 -80.00
Enter budget items:
Enter Housing (current amount $580.00) 678
Enter Utilities (current amount $150.00) 213
Enter Household (current amount $65.00) 78
Enter Transportation (current amount $50.00) 345
Enter Food (current amount $250.00) 123
Enter Medical (current amount $30.00) 98
Enter Insurance (current amount $100.00) 201
Enter Entertainment (current amount $150.00) 23
Enter Clothing (current amount $75.00) 124
Enter Miscellaneous (current amount $50.00) 88
Enter expenses items:
Enter Housing (current amount $580.00) 908
Enter Utilities (current amount $130.00) 23
Enter Household (current amount $50.00) 78
Enter Transportation (current amount $50.00) 93
Enter Food (current amount $230.00) 609
Enter Medical (current amount $30.00) 817
Enter Insurance (current amount $100.00) 22
Enter Entertainment (current amount $120.00) 104
Enter Clothing (current amount $100.00) 85
Enter Miscellaneous (current amount $30.00) 22
*** BUDGET ****
Category Budget Expense Diff
=============================================
Housing 678.00 908.00 230.00
Utilities 213.00 23.00 -190.00
Household 78.00 78.00 0.00
Transportation 345.00 93.00 -252.00
Food 123.00 609.00 486.00
Medical 98.00 817.00 719.00
Insurance 201.00 22.00 -179.00
Entertainment 23.00 104.00 81.00
Clothing 124.00 85.00 -39.00
Miscellaneous 88.00 22.00 -66.00
=============================================
TOTALS 1971.00 2761.00 790.00
Program ended with exit code: 0
|