Commit 53c9dc76 authored by Believer Programmers' Club's avatar Believer Programmers' Club

Merge branch 'branch5.11' into 'master'

michael.davityan:exercise_05_11 See merge request bpcarm/trainings2017!1297
parents ae31a6c5 1b7a0ac7
progname=exercise_05_11
CC=g++
CFLAGS=-Wall -Wextra -Werror -g3
all: test1
debug/$(progname): debug/$(progname).o
$(CC) $(CFLAGS) $< -o $@
debug/%.o: debug/%.s
$(CC) -c $(CFLAGS) $< -o $@
debug/%.s: debug/%.ii
$(CC) -S $(CFLAGS) $< -o $@
debug/%.ii: %.cpp | debug
$(CC) -E $(CFLAGS) $< -o $@
debug:
mkdir -p debug
clean:
rm -r debug Tests/*.out
test%: debug/$(progname)
@./debug/$(progname) < Tests/$@.in > Tests/$@.out 2>&1 || echo "$@ is executing..."
@diff Tests/$@.out Tests/$@.expected && echo PASSED || echo FAILED
.PRECIOUS: debug/%.ii debug/%.s
.SECONDARY: debug/%.ii debug/%.s
==================================================================================
------------------------This table for 5% per annum -----------------------------
==================================================================================
Year Amount on deposit
1 1050.00
2 1102.50
3 1157.62
4 1215.51
5 1276.28
6 1340.10
7 1407.10
8 1477.46
9 1551.33
10 1628.89
==================================================================================
------------------------This table for 6% per annum -----------------------------
==================================================================================
Year Amount on deposit
1 1060.00
2 1123.60
3 1191.02
4 1262.48
5 1338.23
6 1418.52
7 1503.63
8 1593.85
9 1689.48
10 1790.85
==================================================================================
------------------------This table for 7% per annum -----------------------------
==================================================================================
Year Amount on deposit
1 1070.00
2 1144.90
3 1225.04
4 1310.80
5 1402.55
6 1500.73
7 1605.78
8 1718.19
9 1838.46
10 1967.15
==================================================================================
------------------------This table for 8% per annum -----------------------------
==================================================================================
Year Amount on deposit
1 1080.00
2 1166.40
3 1259.71
4 1360.49
5 1469.33
6 1586.87
7 1713.82
8 1850.93
9 1999.00
10 2158.92
==================================================================================
------------------------This table for 9% per annum -----------------------------
==================================================================================
Year Amount on deposit
1 1090.00
2 1188.10
3 1295.03
4 1411.58
5 1538.62
6 1677.10
7 1828.04
8 1992.56
9 2171.89
10 2367.36
==================================================================================
------------------------This table for 10% per annum -----------------------------
==================================================================================
Year Amount on deposit
1 1100.00
2 1210.00
3 1331.00
4 1464.10
5 1610.51
6 1771.56
7 1948.72
8 2143.59
9 2357.95
10 2593.74
==================================================================================
==================================================================================
#include <iostream>
#include <iomanip>
#include <cmath>
int
main()
{
std::cout << std::fixed << std::setprecision(2);
for (int integerRate = 5; integerRate <= 10; ++integerRate) {
double rate = integerRate * 0.01;
double amount = 1000.0;
std::cout << "==================================================================================\n"
<< "------------------------This table for "
<< std::setw(2) << integerRate << "%"
<< " per annum -----------------------------\n"
<< "==================================================================================\n";
std::cout << "Year" << std::setw(21) << "Amount on deposit" << std::endl;
for (int year = 1; year <= 10; ++year) {
amount *= (1.0 + rate);
std::cout << std::setw(4) << year << std::setw(21) << amount << std::endl;
}
}
std::cout << "==================================================================================\n"
<< "==================================================================================" << std::endl;
return 0;
}
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