Commit e21d016c authored by Michael's avatar Michael

michael.davityan:exercise_05_29

parent aced883a
Pipeline #24693372 passed with stage
in 2 minutes 23 seconds
progname=exercise_05_29
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
#include <iostream>
#include <iomanip>
int
main()
{
std::cout << std::fixed << std::setprecision(2);
for (int integerRate = 5; integerRate <= 10; ++integerRate) {
double rate = static_cast<int>(integerRate) * 0.01;
long double amount = 24.0;
std::cout << "==================================================================================\n"
<< "---------------------Peter Minuit Deposite by the years---------------------------\n"
<< "==================================================================================\n"
<< "------------------------This table for " << std::setw(2)
<< static_cast<int>(rate * 100) << "%" << " per annum -----------------------------\n"
<< "__________________________________________________________________________________\n";
std::cout << "Year" << std::setw(25) << "Amount on deposit" << std::endl;
for (int year = 1626; year <= 2018; ++year) {
amount *= (1.0 + rate);
std::cout << std::setw(4) << year << std::setw(25) << amount << std::endl;
}
}
std::cout << "==================================================================================\n"
<< "--------------------------------End of contents-----------------------------------\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