#include <iostream>
using namespace std;
int main(){
int i = 0, j = 0, sks = 0, totalMk = 0;
int opsi, siam, jmlMk, noMk, maxSks, pass, p, krs2 = 1;
float ipk;
string user;
bool login;
string username[5];
int password[5];
string matkul[8] = {
"Bahasa Indonesia (2 sks)","Bahasa Inggris (2 sks)","Rangkaian Elektronika (4 sks)","Sistem Digital (3 sks)",
"Sistem Mikrokontroler (4 sks)","Pemrograman Dasar (3 sks)","Pemrograman Lanjut (4 sks)","Komunikasi Data (2 sks)"
};
string krs[8];
utama :
cout << "1. Registrasi user" << endl;
cout << "2. Login" << endl;
cout<<"pilih opsi: ";
cin >> opsi;
if (opsi == 1){
if (i == 5 && j == 5){
cout << "Maaf, anda telah melebihi batas registrasi akun.";
goto utama;
}
cout << "--REGISTRASI--" << endl;
cout << "Masukkan username : ";
cin.ignore();
getline(cin,username[i]);
i++;
cout << "Masukkan password : ";
cin >> password[j];
j++;
system("cls");
}
else if (opsi == 2){
login = true;
while (login == true){
cout << "--LOGIN--" << endl;
cout << "Masukkan username : ";
cin >> user;
cout << "Masukkan password : ";
cin >> pass;
if (user == username[0] && pass == password[0] || user == username[1] && pass == password[1] ||
user == username[2] && pass == password[2] || user == username[3] && pass == password[3] ||
user == username[4] && pass == password[4] ){
login = false;
}
else {
cout << "Username tidak terdaftar di database kami, silahkan registrasi dahulu." << endl;
goto utama;
}
}
}
menu :
cout << endl;
cout << "Selamat datang di siam ub" << endl;
cout << "1. Pilih KRS" << endl;
cout << "2. Print KRS" << endl;
cout << "3. Logout" << endl;
cout << "Masukkan pilihan siam : ";
cin >> siam;
if (siam == 1){
goto pilih;
}
else if (siam == 2){
goto cetak;
}
else if (siam == 3){
goto utama;
}
pilih :
cout << "Masukkan IPK : ";
cin >> ipk;
cout << endl;
if (ipk >= 3 && ipk <= 4){
cout << "Jumlah SKS kamu semester ini maksimal : 24" << endl;
maxSks = 24;
}
else {
cout << "Jumlah SKS kamu semester ini maksimal : 20" << endl;
maxSks = 20;
}
cout << "Matakuliah yang tersedia : " << endl;
cout << "1. " << matkul[0] << endl;
cout << "2. " << matkul[1] << endl;
cout << "3. " << matkul[2] << endl;
cout << "4. " << matkul[3] << endl;
cout << "5. " << matkul[4] << endl;
cout << "6. " << matkul[5] << endl;
cout << "7. " << matkul[6] << endl;
cout << "8. " << matkul[7] << endl;
cout << "Ingin mengambil berapa mata kuliah ? : ";
cin >> jmlMk;
if (jmlMk > 8){
cout << "Maaf, jumlah mata kuliah yang bisa anda ambil maksimal 8." << endl;
return 0;
}
else{
goto ambil;
}
ambil :
cout << endl;
if (totalMk == jmlMk){
cout << endl << endl;
goto menu;
}
cout << "Masukkan nomor mata kuliah 1-8 : ";
cin >> noMk;
if (noMk == 1){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[0]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[0];
sks += 2;
krs[krs2] = matkul[0];
krs2++;
totalMk += 1;
goto ambil;
}
else if (noMk == 2){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[1]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[1];
sks += 2;
krs[krs2] = matkul[1];
krs2++;
totalMk += 1;
goto ambil;
}
else if (noMk == 3){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[2]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[2];
sks += 4;
krs[krs2] = matkul[2];
krs2++;
totalMk += 1;
goto ambil;
}
else if (noMk == 4){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[3]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[3];
sks += 3;
krs[krs2] = matkul[3];
krs2++;
totalMk += 1;
goto ambil;
}
else if (noMk == 5){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[4]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[4];
sks += 4;
krs[krs2] = matkul[4];
krs2++;
totalMk += 1;
goto ambil;
}
else if (noMk == 6){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[5]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[5];
sks += 3;
krs[krs2] = matkul[5];
krs2++;
totalMk += 1;
goto ambil;
}
else if (noMk == 7){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[6]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[6];
sks += 4;
krs[krs2] = matkul[6];
krs2++;
totalMk += 1;
goto ambil;
}
else if (noMk == 8){
for (p = 0; p < 8; p++){
if (krs[p] == matkul[7]){
cout << "SKS melebihi batas atau terdapat matakuliah yang sama." << endl;
goto ambil;
}
}
cout << matkul[7];
sks += 2;
krs[krs2] = matkul[7];
krs2++;
totalMk += 1;
goto ambil;
}
cetak :
system("cls");
cout << "KRS Akademik Universitas Brawijaya." << endl;
cout << "Mata kuliah yang anda ambil semester ini : " << endl;
for (int k = 1; k <= totalMk; k++){
cout << k << ". " << krs[k];
cout << endl;
}
goto menu;
return 0;
}