akbarbasya26

latihan kuis v2

Jan 6th, 2020
143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <stdlib.h>
  3. using namespace std;
  4.  
  5. int nilai_akhir(int tugas, int uts, int uas){
  6. return (tugas * 0.5) + (uts * 0.2) + (uas * 0.3);
  7. }
  8. main (){
  9. int percobaan = 0, nilai_akhir, tugas, uas, uts;
  10. char nama[50], mata_kuliah[30], dosen[50];
  11. long nim;
  12. string password, status, grade;
  13. do{
  14. cout << "[!] Masukkan password : "; cin >> password;
  15. percobaan = percobaan + 1;
  16. if (percobaan==3){
  17. cout << "Anda telah salah password 3x,Program berhenti !";
  18. exit(EXIT_FAILURE);
  19. }
  20. }while (password != "akbar2612");
  21. system("CLS");
  22. cout << "Selamat datang !!" << endl;
  23. cout << "Masukkan Nama anda : "; cin >> nama;
  24. cout << "Masukkan NIM anda : " ; cin >> nim;
  25. cout << "Masukkan Mata kuliah : "; cin >> mata_kuliah;
  26. cout << "Dosen anda : "; cin >> dosen;
  27. cout << "Masukkan nilai tugas : "; cin >> tugas;
  28. cout << "Masukkan nilai UAS : "; cin >> uas;
  29. cout << "Masukkan nilai UTS : "; cin >> uts;
  30. if (tugas > 60){
  31. status = "Lulus";
  32. }else{
  33. cout << " [!] Anda tidak lulus";
  34. exit(EXIT_FAILURE);
  35. }
  36. if (nilai_akhir > 85 && nilai_akhir < 100){
  37. grade = "A";
  38. status = "Lulus";
  39. }else if (nilai_akhir > 75 && nilai_akhir < 84){
  40. grade = "B";
  41. status = "Lulus";
  42. }else if (nilai_akhir > 60 && nilai_akhir < 74){
  43. grade = "C";
  44. status = "Lulus";
  45. }else if (nilai_akhir > 40 && nilai_akhir < 59){
  46. grade = "D";
  47. status = "Tidak Lulus";
  48. }else{
  49. grade = "E";
  50. status = " Tidak Lulus";
  51. }
  52. system("CLS");
  53. cout << "Nama : " << nama << endl;
  54. cout << "NIM : " << nim << endl;
  55. cout << "Mata kuliah : " << mata_kuliah << endl;
  56. cout << "Dosen anda : " << dosen << endl;
  57. cout << "Nilai Akhir anda : " << nilai_akhir << endl;
  58. cout << "Grade : " << grade << endl;
  59. cout << "Status : " << status << endl;
  60. }
RAW Paste Data