Created
October 18, 2017 02:44
-
-
Save RianWardana/13674f9ec5e51805444bee0a2c3bd1c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define SIZE 11 | |
long int tabungan[] = {0,100,60,50,150,10,300,25,70,35,250}; | |
void cetakHeader(); | |
void enter(); | |
void cetakArray(); | |
void menuSaldoKumulatif(); | |
void menuPoinTahunan(); | |
void kaliSejuta(int array[], int size); | |
int saldoKumulatif(int idKustomer, int bulan); | |
int poinTahunan(int idKustomer, int tahun); | |
int main() { | |
kaliSejuta(tabungan, SIZE); | |
int customerID, pilihan; | |
cetakHeader(); | |
printf("Tulis Customer ID Anda: "); | |
scanf(" %d", &customerID); | |
enter(1); | |
printf("Tulis 1 untuk menghitung saldo kumulatif"); | |
enter(1); | |
printf("Tulis 2 untuk menghitung poin tahunan"); | |
enter(1); | |
printf("Pilihan Anda: "); | |
scanf(" %d", &pilihan); | |
switch(pilihan) { | |
case 1: | |
menuSaldoKumulatif(customerID); | |
break; | |
case 2: | |
menuPoinTahunan(customerID); | |
break; | |
} | |
} | |
void cetakArray(int array[], int size) { | |
int k; | |
for (k = 0; k < size; k++) { | |
printf("%d ", array[k]); | |
} | |
} | |
// passing parameter, by reference | |
void kaliSejuta(int array[], int size) { | |
int k; | |
for (k = 0; k < size; k++) { | |
array[k] = array[k] * 1000000; | |
} | |
} | |
int saldoKumulatif(int idKustomer, int bulan) { | |
int k; | |
int saldo = tabungan[idKustomer]; | |
for (k = 0; k < bulan; k++) { | |
// menghitung saldo terpotong biaya administrasi dengan ternary operator | |
saldo = saldo - (saldo <= 100000000 ? 25000 : 100000); | |
// menghitung saldo ditambah bunga | |
saldo = saldo + (0.02*saldo); | |
} | |
return saldo; | |
} | |
int poinTahunan(int idKustomer, int tahun) { | |
int k, saldoTahunan; | |
int poin = 0; | |
for (k = 0; k < tahun; k++) { | |
saldoTahunan = saldoKumulatif(idKustomer, 12*tahun); | |
poin = poin + (saldoTahunan/1250000); | |
} | |
return poin; | |
} | |
void menuSaldoKumulatif(int customerID) { | |
int bulan; | |
cetakHeader(); | |
printf("Tulis durasi menabung (bulan): "); | |
scanf(" %d", &bulan); | |
enter(1); | |
printf("Saldo kumulatif Anda untuk tabungan selama %d bulan sebesar:", bulan); | |
enter(1); | |
printf("Rp %d", saldoKumulatif(customerID, bulan)); | |
} | |
void menuPoinTahunan(int customerID) { | |
int tahun; | |
cetakHeader(); | |
printf("Tulis durasi menabung (tahun): "); | |
scanf(" %d", &tahun); | |
enter(1); | |
printf("Poin Anda untuk tabungan selama %d tahun sebesar:", tahun); | |
enter(1); | |
printf("%d Poin", poinTahunan(customerID, tahun)); | |
} | |
void cetakHeader() { | |
system("cls"); | |
printf(" ___________________________________\n"); | |
printf("| PROGRAM UTS ALGORITMA-PEMROGRAMAN |\n"); | |
printf("| TOTAL TABUNGAN NASABAH BANK |\n"); | |
printf("| NURIAN S. WARDANA |\n"); | |
printf("| (1506717071) |\n"); | |
printf("+-----------------------------------+\n\n"); | |
} | |
void enter(int jumlah) { | |
int k; | |
for (k = 0; k < jumlah; k++) printf("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment