5a 1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

#include <iostream>

#include <windows.h>
#include <array>
#include <algorithm>
using namespace std;

array <string, 12> nama;


array <int, 12> nim;
array <int, 12> sortirnim;
int no;
char yt;

void tampilawal() // tampilan awal


{
system("color E0");
system("cls");
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout << "~~~ Data Mahasiswa ~~~\n";
cout << "~~~ Politeknik ATMI Surakarta ~~~\n";
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout << endl << endl;
}

void prodi(int x, int y) // fungsi menentkan prodi sesuai nim


{
int prod = 0;

if (y == 0)
{
prod = nim[x] % 10000;
}
else if (y == 1)
{
prod = sortirnim[x] % 10000;
}

if (prod >= 1000 && prod < 2000)


{
cout << "TMI ";
}
else if (prod >= 2000 && prod < 3000)
{
cout << "TMK ";
}
else if (prod >= 3000 && prod < 4000)
{
cout << "TPM ";
}
else if (prod >= 4000 && prod < 5000)
{
cout << "RTM ";
}
else if (prod >= 5000 && prod < 6000)
{
cout << "PM ";
}
else if (prod >= 6000 && prod < 7000)
{
cout << "TRMK";
}
}

void jenjang(int i, int j) // untuk menentukan jenjang sesuai nim


{
int d = 0;

if (j == 0)
{
d = nim[i] % 10000;
}
else if (j == 1)
{
d = sortirnim[i] % 10000;
}

if (d >= 1000 && d < 4000)


{
cout << "D3";
}
else if (d >= 4000 && d < 7000)
{
cout << "D4";
}
}

void namamahasiswa() // untuk sortir nama sesuai nim


{
int ceknama;

for (ceknama = 0; ceknama < 12; ceknama++)


{
if (sortirnim[no] == nim[ceknama])
{
cout << nama[ceknama];
}
}
}

int main()
{
awal:
tampilawal();

// input data mahasiswa


for (no = 0; no < 12; no++)
{
cout << "Masukkan Data Mahasiswa ke " << no + 1 << endl;
cout << "Nama : "; cin >> nama[no]; // input nama mahasiswa
cout << "NIM : "; cin >> nim[no]; // input nim mahasiswa
cout << endl;
}

tampil:
cout << endl;
cout << "Tampilkan Daftar Mahasiswa [y/t]? "; // konfirmasi proses
cin >> yt;
cout << endl;
if (yt == 'Y' || yt == 'y') {
tampilawal();
cout << " \tNIM\t PRODI JENJANG NAMA " << endl; //
menampilkan data mahasiswa
cout << "----------------------------------------------" << endl;
for (no = 0; no < 12; no++)
{
cout << " " << nim[no] << "\t "; prodi(no, 0);
cout << " "; jenjang(no, 0);
cout << " " << nama[no] << endl;
}

sortir:
cout << endl;
cout << "Sortir Data Mahasiswa [y/t]? "; // konfirmasi sortir data
cin >> yt;
cout << endl;
if (yt == 'Y' || yt == 'y') {
int a, b, c, d = 11, save, sort;

for (no = 0; no < 12; no++)


{
sortirnim[no] = nim[no];
}

for (a = 0; a < 12; a++) // fungsi sortir nim


{
sort = 0;
for (b = 1; b <= d; b++)
if (sortirnim[b] > sortirnim[sort])
sort = b;
save = sortirnim[d];
sortirnim[d] = sortirnim[sort];
sortirnim[sort] = save;
d--;
}

tampilawal();
cout << " \tNIM\t PRODI JENJANG NAMA " << endl; //
menampilkan data mahasiswa setelah disortir
cout << "----------------------------------------------" << endl;
for (no = 0; no < 12; no++)
{
cout << " " << sortirnim[no] << "\t "; prodi(no, 1);
cout << " "; jenjang(no, 1);
cout << " "; namamahasiswa();
cout << endl;
}
}
else if (yt == 'T' || yt == 't') {
goto ulang;
}
else {
goto sortir;
}
}
else if (yt == 'T' || yt == 't') {
goto ulang;
}
else
{
goto tampil;
}

ulang:
cout << endl;
cout << "Apakah Anda Ingin Memasukkan Data Lagi [y/t] ? "; // konfirmasi
pengulangan
cin >> yt;
cout << endl;
if (yt == 'Y' || yt == 'y') {
goto awal;
}
else if (yt == 'T' || yt == 't') {
goto akhir;
}
else {
goto ulang;
}
akhir:
return 0;
}

You might also like