Guest User

Untitled

a guest
Mar 13th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void if_correct()
  6. {
  7. int menu_keuze;
  8.  
  9. printf("What would you like to do?\n\n");
  10. printf("1: Dollar To Euro\t 2:Launch A Missile\t 3:Log Out\n");
  11. scanf("%i",&menu_keuze);
  12. printf("\n");
  13. if(menu_keuze==1)
  14. {
  15. float dollar=1.47;
  16. float omrekenen;
  17. float totaal;
  18. printf("Hoeveel dollars wilt u omrekenen?\n");
  19. scanf("%f",&omrekenen);
  20. totaal=omrekenen/dollar;
  21. printf("%.2f\n\n",totaal);
  22. if_correct();
  23. }
  24. else if(menu_keuze==2)
  25. {
  26. int start_nummer;
  27.  
  28. printf("Count down from?\n");
  29. scanf("%i",&start_nummer);
  30. printf("\n");
  31.  
  32. while(start_nummer!=0)
  33. {
  34. printf("%i seconds till launch!\n\n",start_nummer);
  35. start_nummer--;
  36. }
  37. printf("Take cover! Takeoff! BoOoOoOoOom!\n\n");
  38. if_correct();
  39. }
  40. else if(menu_keuze==3)
  41. {
  42. main();
  43. }
  44. else if(menu_keuze!=1||2||3)
  45. {
  46. printf("Enter a valid menu option\n!");
  47. if_correct();
  48. }
  49. }
  50.  
  51. int main()
  52. {
  53. char username[10];
  54. char user[10];
  55. char password[10];
  56. char pass[10];
  57. int times=0;
  58. int end=0;
  59. int i=0;
  60. int settings_set;
  61.  
  62. while((end==0)&&(times < 3))
  63. {
  64. printf("nieuwe username:\n");
  65. scanf("%s",username);
  66. printf("\n");
  67. printf("nieuwe password:\n");
  68. scanf("%s",password);
  69. settings_set=1;
  70. printf("\n");
  71. printf("username:\n");
  72. scanf("%s",user);
  73. printf("\n");
  74. printf("password:\n");
  75. scanf("%s",pass);
  76. printf("\n");
  77. //printf("%s %s %s %s\n",username,user,password,pass); <-- controleert of de waarden goed worden opgenomen door scanf
  78. if(strcmp(username,user)==0 && strcmp(password,pass)==0)
  79. {
  80. printf("correct\n\n");
  81. end++;
  82. if_correct(); /*Roept if_correct()*/
  83. }
  84. else if(strcmp(username,user)!=0 || strcmp(password,pass)!=0)
  85. {
  86. printf("fout\n");
  87. times++;
  88. if(times==3)
  89. {
  90. printf("U heeft 3 maal de verkeerde gegevens ingevuld, herstart het programma!\n");
  91. }
  92. else /* if(times!=3) <-- optioneel */
  93. {
  94. printf("Dit is maal %i dat u verkeerde gegevens ingeeft, na de 3de keer moet u het programma herstarten!\n\n",times);
  95. }
  96. }
  97. else /*dit moet niet kunnen gebeuren*/
  98. {
  99. printf("An anknown error has occurred, try again please!\n");
  100. main();
  101. }
  102. } // einde while
  103. return(0);
  104. }
Add Comment
Please, Sign In to add comment