Advertisement
Guest User

Code_Review_For_Divulger_Michealson

a guest
Aug 4th, 2015
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 11.33 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <math.h>
  3. #include <complex.h>
  4. #include <ctype.h>>
  5. #include <string.h>
  6.  
  7. int main(){
  8. /*Programming Block
  9. Program Name: A.K.A Combination Calculator@
  10.  
  11. Developer: Mike Divulger
  12.  
  13. About: This is a calculator that can do basic additions for you
  14. you just need to insert two numbers and you will get the end product
  15.  
  16. variable: char B;
  17. char k;
  18. int e, f, p, u, r;
  19. char K;
  20. char T;
  21. char R;
  22. int Sad,Das,Asd,Ads,Com;
  23. int Z;
  24. char pp;
  25. int Tion,tion,Sion,sion,Sick,sick,Pit,pit;
  26.  
  27. constant: N/A
  28.  
  29. Sturture: Block Programming Style
  30.  
  31. Language: Yea its Typically C partially dumb.
  32.  
  33. So dive in and it will please you
  34.  
  35. and oh i almost forgot dont ask me anything i so cannot explain why i built this
  36.  
  37. */
  38.  
  39.  
  40. char B;
  41. char k;
  42. int e, f, p, u, r;
  43. char K;
  44. char T;
  45. char R;
  46. int Sad,Das,Asd,Ads,Com;
  47. int Z;
  48. char pp;
  49. int Tion,tion,Sion,sion,Sick,sick,Pit,pit;
  50.  
  51.  
  52. for(Z=0; Z<15; Z++){
  53.     if(Z<15){//THESE 2 LINES ARE NOT NECESSARY.
  54.         Z++; //THEY CAUSE DOUBLE COUNTING
  55.  
  56.  
  57.         printf("This is a Full Maths Program Do you Want to continue......? (Y/N)\n");
  58.         scanf(" %c", &T);
  59.         if( (T=='y')||(T=='Y')||(T=='Yes') ){ //T=='Yes' does not work because it is not a string, it is a character.
  60.             printf("Do You Want to Add, sub, Div, Mul? 'Y,y' If you want to continue or 'N,n' If you want to do some other operations (Y/N)\n");//THATS CONFUSING, MAYBE WORD IT "If you want to Add,sub, multiply, or divide, enter Y; other operations enter N"
  61.             scanf(" %c", &k);
  62.  
  63.             if( (k=='Y')||(k=='y') ){
  64.                 printf("What Operation Do You Want To Do?\n\t""A) Addition\n\t""B) Subtraction\n\t""C) Division\n\t""D) Multiplication\n\t""E) All\n");
  65.                 scanf(" %c", &B);
  66.  
  67.                 if( (B == 'a')||(B == 'A') ){
  68.                     printf("Enter The Two numbers Below\n");
  69.                     scanf(" %i", &e);
  70.                     scanf(" %i", &f);
  71.                     printf("The Sum of %i + %i = %i\n\n", e, f, e + f);
  72.  
  73.  
  74.                 }else if( (B == 'B')||(B == 'b') ){
  75.                     printf("Enter The Two numbers Below\n");
  76.                     scanf(" %i", &e);//Note to self, %i is the same as %d, this threw me off.
  77.                     scanf(" %i", &f);
  78.                     printf("The Remainder of %i - %i = %i\n\n", e, f, e - f);
  79.                 }else if( (B == 'c')||(B == 'C') ){
  80.                     printf("Enter The Two numbers Below\n");
  81.                     scanf(" %i", &e);
  82.                     scanf(" %i", &f);
  83.                     printf("The Quetient of %i / %i = %i\n\n", e, f, e / f);
  84.  
  85.                 }else if( (B == 'd')||(B == 'D') ){
  86.                     printf("Enter The Two numbers Below\n");
  87.                     scanf(" %i", &e);
  88.                     scanf(" %i", &f);
  89.                     printf("The Result of %i * %i = %i\n\n", e, f, e * f);
  90.                 }else if( (B == 'E')||(B == 'e') ){
  91.  
  92.                     printf("These Are the Operation you will Be running Enter:\n\t""A) Addition\n\t""B) Subtraction\n\t""C) Division\n\t""D) Multiplication\n");
  93.                     scanf(" %c", &B);
  94.                     int F;
  95.                     for(F=16; F>=16; F++){ //This is an infinite loop, also you have the double call to the counter.
  96.  
  97.                         F++; //This is the double call to the counter, unnecessary.
  98.                         if( (B == 'a')||(B == 'A') ){
  99.                             printf("Enter The Two numbers You want the sum of Below\n");
  100.                             scanf(" %i", &tion);
  101.                             scanf(" %i", &Tion);//What is Tion supposed to represent?
  102.                             printf("The Sum of %i + %i = %i\n\n",tion, Tion, Tion+tion );
  103.                             continue;
  104.                         }
  105.  
  106.                         else if( (B == 'B')||(B == 'b') ){
  107.                             printf("Enter The numbers you want to sunbtract Below\n");
  108.                             scanf(" %i", &sion);//What's sion? Add a c, Scion and we are counting cars, that's what I think when I see this.
  109.                             scanf(" %i", &Sion);
  110.                             printf("The Remainder of %i - %i = %i\n\n", sion, Sion, sion - Sion);
  111.                             continue;
  112.                         }
  113.                         else if( (B == 'C')||(B == 'c') ){
  114.                             printf("Enter The Two numbers you want to divide Below\n");
  115.                             scanf(" %i", &Sick);//Sick? What's sick? I mean I know it's the variables we use to divide 2 numbers, but your variables are supposed to represent them. Maybe Div1 and Div2?
  116.                             scanf(" %i", &sick);
  117.                             printf("The Quetient of %i / %i = %i\n\n",Sick, sick, Sick / sick );
  118.                             continue;
  119.                         }
  120.                         else if( (B == 'D')||(B == 'd') ){
  121.                             printf("Enter The Two numbers you want to multiply Below\n");
  122.                             scanf(" %i", &Pit);//This is the [pit]fall of society.
  123.                             scanf(" %i", &pit);
  124.                             printf("The Result of %i * %i = %i\n\n",Pit, pit, Pit * pit);
  125.                             break;
  126.                         }else{
  127.                             printf("Invalid Response\a\n\n");
  128.                         }
  129.                     }
  130.  
  131.                 }
  132.  
  133.                 else{
  134.                     printf("Invalid Response!!!!\a\n");
  135.                     printf("********************************************************************************\n\n");
  136.                 }
  137.             }else if( (k=='n')||(k=='N') ){
  138.                 printf("\nDo you want to move on?(Y/N)\n");
  139.                 scanf(" %c", &K);
  140.  
  141.                 if( (K=='Y')||(K=='y') ){
  142.                     char n; //What in the world do these 6 lines do? What is it calculating? Comment your code.
  143.                     int l= e + f;
  144.                     int m= e - f;
  145.                     int v= e / f;
  146.                     int o= e * f;
  147.                     float avg;
  148.  
  149.                     printf("\nDo you Want To Check the Average Of Addition and Subtraction, Division & Mutiplication ? Or You Wan to do All? (Y/N/All/A)\n"); //Again this is a single character, you can't put "all" in the input. Don't encourage user to do so. Not sure but I believe this could result in a stack overflow.
  150.  
  151.                     scanf(" %c", &n);
  152.                     if( (n == 'Y') ||(n=='y')){
  153.                         printf("Enter the numbers you Want the varage of\n"); //Note you forgot the 'a' in "average" and also misspelled it.
  154.                         scanf(" %i\n", &l);
  155.                         scanf(" %i\n", &m);
  156.                         scanf(" %i\n", &o);
  157.                         scanf(" %i", &v);
  158.  
  159.                         avg = (l+m+v+o) / 4; //Could make these 6 lines better to accept a larger set of numbers with a loop and an array.
  160.                         printf("\nThe Average of the above is: %.2f\n\n", avg);
  161.                     }else if( (n=='a')||(n=='All')||(n=='A') ){ //Look up how to lower case all letters of input to make this more efficient. So even if they put "aLl" this would be able to be run and you wouldn't have to include 'A' condition.
  162.  
  163.                         printf("Are you sure\n");
  164.                         scanf(" %c", &R);
  165.                         if( (R=='y')||(R=='Y') ){
  166.                             printf("Enter the numbers You want to calculate\n");
  167.                             scanf(" %i", &Das);
  168.                             scanf(" %i", &Sad);
  169.                             scanf(" %i", &Asd);
  170.                             scanf(" %i", &Ads);
  171.                             Com = (Das + Sad + Asd + Ads) / 4;
  172.                             printf("\nThe Average of the Number %i + %i + %i + %i = %i\n", Das, Sad, Asd, Ads, Com);
  173.                             printf("********************************************************************************\n\n");
  174.  
  175.  
  176.                         }else if( (R=='n')||(R=='N') ){
  177.  
  178.                             printf("\n Enter your name Below\n"); //Why in the world does this Name feature need to be here? If you put it here, at least put "Thank you %s for using my program. Goodbye."
  179.                             scanf(" %c", &pp);
  180.                             if(pp==pp){
  181.                                 printf(" %c Thank you for using this program Goodbye\n\n", pp);
  182.  
  183.                             }else{ //This will never be run, you don't even need an if.
  184.                                 printf("Invalid Response!!!!\a");
  185.                                 printf("********************************************************************************\n\n");
  186.                             }
  187.  
  188.                         }else{
  189.                             printf("Invalid Response!!!!\a");
  190.                             printf("********************************************************************************\n\n");
  191.  
  192.                         }
  193.  
  194.                     }else if( (n == 'n')||(n == 'N') ){
  195.                         printf("Thanks for that in we will See you Again!!!");
  196.                         printf("********************************************************************************\n\n");
  197.  
  198.  
  199.                     }else{
  200.                         printf("Invalid Response!!!!\a");
  201.                         printf("********************************************************************************\n\n");
  202.                     }
  203.                 }else if( (K=='nothing')||(K=='n')||(K=='N') ){
  204.  
  205.                     printf("Thanks For Attempting This Program Goodbye!!\n");
  206.                     printf("********************************************************************************\n");
  207.  
  208.  
  209.                 }else{
  210.                     printf("Invalid Response!!!!\a\n");
  211.                     printf("********************************************************************************\n\n");
  212.                 }
  213.  
  214.  
  215.             }
  216.         }else if( (T=='n')||(T=='N')||(T=='No') ){
  217.             printf("Well Now Is The Time To Leave!!!!\n");
  218.             printf("********************************************************************************\n\n");
  219.             break;
  220.  
  221.         }else{
  222.             printf("Invalid Response You Numskull!!!\a\n");
  223.             printf("********************************************************************************\n\n");
  224.         }
  225.     }
  226. }
  227.  
  228. return 0;
  229. }
  230.  
  231. /*******************FINAL NOTES, CITATION FOR CODE REVIEW**********************************
  232. @CODE_REVIEWER: David Green
  233. @CODE_REVIEWER_CONTACT: pbcub1.dg@gmail.com
  234. @CODE_REVIEW_DATE: Aug/4/2015
  235.  
  236. @FINAL_NOTES:
  237. Over all, there were quite a bit of bugs, but this is good for your review and improvement. Look up stack overflow, and also you can
  238. use the same variables for input, you might have to empty them first but it can be done, and would help with the jumbled declearations at the top. This
  239. is a good calculator if you get it fixed and is good for practice. Keep practicing, you can contact me and I would review your code again if you want.
  240. Also arrays could be used to input a larger number of input values for you to calculate. Also using floats or doubles could give the user a better precision.
  241. Thank you for writing this and publishing it so I can review it, I need to practice my comprehension of code, as all programmers should, and it also
  242. helps people to review code.
  243. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement