Commit bceb33c1 by Karine

Exercise_05_11, Version1

parent 9daac871
exercise_05_11: main.o | .gitignore
g++ $^ -o $@
main.ii: main.cpp
g++ -E $^ -o $@
main.s: main.ii
g++ -S $^ -o $@
main.o: main.s
g++ -c $^ -o $@
.gitignore:
echo "exercise_05_11" > $@
clean:
rm *.ii *.s *.o *.out exercise_05_11 .gitignore
test: exercise_05_11
@./exercise_05_11 > test.out
@diff test.out test.expected > /dev/null 2>&1 && echo PASSED || echo FAILED
.PRECIOUS: main.ii main.s
.SECONDARY: main.ii main.s
#include <iostream>
int
main()
{
std::cout << "Year\t" << "Amount of deposit" << std::endl;
for (int rate = 5; rate <= 10; ++rate) {
std::cout << "Rate:\t" << rate << "%" << std::endl;
double accumulation = 1.0 + rate / 100.0;
double principal = 1000.0;
for (int year = 1; year <= 10; ++year) {
principal *= accumulation;
std::cout << year << ":\t" << principal << std::endl;
}
std::cout << std::endl;
}
return 0;
}
Year Amount of deposit
Rate: 5%
1: 1050
2: 1102.5
3: 1157.62
4: 1215.51
5: 1276.28
6: 1340.1
7: 1407.1
8: 1477.46
9: 1551.33
10: 1628.89
Rate: 6%
1: 1060
2: 1123.6
3: 1191.02
4: 1262.48
5: 1338.23
6: 1418.52
7: 1503.63
8: 1593.85
9: 1689.48
10: 1790.85
Rate: 7%
1: 1070
2: 1144.9
3: 1225.04
4: 1310.8
5: 1402.55
6: 1500.73
7: 1605.78
8: 1718.19
9: 1838.46
10: 1967.15
Rate: 8%
1: 1080
2: 1166.4
3: 1259.71
4: 1360.49
5: 1469.33
6: 1586.87
7: 1713.82
8: 1850.93
9: 1999
10: 2158.92
Rate: 9%
1: 1090
2: 1188.1
3: 1295.03
4: 1411.58
5: 1538.62
6: 1677.1
7: 1828.04
8: 1992.56
9: 2171.89
10: 2367.36
Rate: 10%
1: 1100
2: 1210
3: 1331
4: 1464.1
5: 1610.51
6: 1771.56
7: 1948.72
8: 2143.59
9: 2357.95
10: 2593.74
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment