irwan94

alfa2

Jan 3rd, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio>
  3. #include <stdlib>//stdlibb buat fungsi exit
  4.  
  5. struct alfamart {
  6. int login;
  7. char nip[20],pass[20];
  8. };
  9. //fungsi garis
  10. void garis(){
  11. cout<<"-=============================================================-"<<endl;
  12. }
  13. //fungsi Judul
  14. void header(){
  15. garis();
  16. cout<<"\t\tPT SUMBER ALFARIA TRIJAYA (ALFAMART)"<<endl;
  17. cout<<"\t\t\tJL TASIKMALAYA NO 56 "<<endl;
  18. garis();
  19. }
  20.  
  21. //fungsi login kedua
  22. void masuk(){
  23. alfamart login;
  24. header();
  25. int sapas=1;//salah password
  26. do{//Melakukan pengulangan jika sebanyak tiga kali jika salah password
  27. cout<<"NIP\t\t :";cin>>login.nip;
  28. cout<<"PASSWORD\t :";cin>>login.pass;
  29. if(strcmp(login.nip,"12345")==0&& strcmp(login.pass,"54321")==0 ){
  30. cout<<"true";
  31. sapas=3;
  32. }else{
  33. cout<<"false";
  34. sapas+=1;
  35. }
  36. }
  37. while(sapas<3);
  38.  
  39. }
  40.  
  41. //fungsi login pertama
  42. void login1(){
  43. alfamart login;
  44. header();
  45. cout<<"1.MASUK"<<endl;
  46. cout<<"2.KELUAR"<<endl<<endl<<endl;
  47. cout<<"Silahkan Input [1/2] :";cin>>login.login;
  48. if(login.login==1){
  49. clrscr();
  50. masuk();
  51. }else{
  52. exit(1);
  53. }
  54. }
  55.  
  56. //=================MAIN=====================
  57. main(){
  58. login1();
  59.  
  60. getch();
  61. }
  62. //================END MAIN =================
Advertisement
Add Comment
Please, Sign In to add comment