Source Sensus Penduduk

#include<iostream.h>
#include<conio.h>
main()
{
int i;
int as,ts,pa;
int penduduk, lahir, mati, jumlah,total=0;
cout << "Tahun awal sensus: ";cin >> as;
cout << "Jumlah tahun sensus: ";cin >> ts;
cout << "Jumlah penduduk awal: ";cin >> pa;



cout<< "|----|--------|----------------|-------------|-------------|----------------|\n";
cout<< "| NO | Tahun | Penduduk | Lahir | Mati | Jumlah |\n";
cout<< "|----|--------|----------------|-------------|-------------|----------------|\n";

penduduk=pa;

for (i=0;i<=ts;i++)
{
lahir= (15./100) * penduduk;
mati= (2./100) * penduduk;
jumlah = penduduk + (lahir-mati);
cout << "| " << i +1 << " | " << as + i << " | " << penduduk << " | " << lahir << " | " << mati << " | " << jumlah << " |" << endl;
penduduk = jumlah;total=total+jumlah;
}
cout<< "|----|--------|----------------|-------------|-------------|----------------|\n";
cout<< "| Total: "<<total << endl;
cout<< "|----|--------|----------------|-------------|-------------|----------------|\n";
}

Tidak ada komentar:

Posting Komentar