Monday, December 9, 2019
Critical Thinking And Problem Solving For IT - Myassignmenthelp.Com
  Questions:  1.A pseudo-code that reads eleven numbers from the user and prints the average of these eleven numbers. Also counts the occurrence of number 6 in the program.  2.A Pseudo Code that reads a positive integer fromuserand finds the average of all even numbers between 1 and users input.  3.Apseudo codethat reads the data fromuseruntil dummy value 999 encountered and print some results based on this data.      Answers:    Answer 1:  A pseudo-code that reads eleven numbers from the user and prints the average of these eleven numbers. Also counts the occurrence of number 6 in the program.    //MAIN MODULE  CREATE AVERAGE_OF_NUMBERS   //an object created to give a call to other modules   CREATE object for AVERAGE_OF_NUMBERS   COMPUTE_INITIALIZE_VARIABLES   COMPUTE_CALCULATE_AVERAGE   COMPUTE_DISPLAY_AVERAGE  END  //INITIALIZATION MODULE  CREATE INITIALIZE_VARIABLES   //create array  DECLARE and INITIALIZE MEMORY TO ARRAY ELEVEN_NUMBERS[ ]  INITIALIZE an integer CLOCK to value 0  INITIALIZE an integer SUM to value 0  DECLARE a decimal variable AVERAGE  INITIALIZE an integer i to value 1  END  //CALCULATION MODULE  CREATE CALCULATE_AVERAGE   REPEAT   READ ELEVEN_NUMBERS[i]  //populate array   IF ELEVEN_NUMBERS[i] equals 6 //check for the occurrence of number 6   INCREMENT CLOCK by 1  //counter incremented in case number 6 found   END IF   UNTIL i equals 11 //Auto increments value of i and checks the condition SET i = 1   REPEAT    Set SUM = SUM + ELEVEN_NUMBERS[i]   UNTIL i = 11   SET AVERAGE = SUM / 11  END  //OUTPUT MODULE  CREATE DISPLAY_AVERAGE   PRINT AVERAGE //display average of eleven numbers   PRINT CLOCK //display multiple occurrence of number 6  END    Answer 2:  A Pseudo Code that reads a positive integer from user and finds the average of all even numbers between 1 and users input.  //MAIN MODULE  CREATE AVERAGE_OF_EVEN_NUMBERS  CREATE object for AVERAGE_OF_EVEN_NUMBERS   COMPUTE_INITIALIZE_VARIABLES  COMPUTE_READ_MAX_LIMIT   COMPUTE_CALCULATE_EVEN_AVERAGE   COMPUTE_DISPLAY_EVEN_AVERAGE  END  //INITIALIZATION MODULE  CREATE INITIALIZE_VARIABLES   DECLARE a decimal variable AVERAGE  INITIALIZE an integer P to value 0  INITIALIZE an integer CLOCK to value 0  INITIALIZE an integer I to value 1  INITIALIZE an integer SUM to value 0  END  //INPUT MODULE  CREATE READ_MAX_LIMIT   PRINT INPUT A POSITIVE INTEGER   WHILE P   READ P   IF P=0 //Validation Check   PRINT INVALID INPUT: PLEASE RE-TRY   //Error message printed if validation fails   END IF   END WHILE  END  // CALCULATION MODULE  CREATE CALCULATE_EVEN_AVERAGE   REPEAT   IF I MOD 2 EQUAL 0   SET SUM = SUM + I   SET CLOCK = CLOCK + 1   END IF   UNTIL I=P //Auto increments value of i and checks the condition   SET AVERAGE = SUM/CLOCK  END  //OUTPUT MODULE  CREATE DISPLAY_EVEN_AVERAGE   PRINT AVERAGE  END      Answer 3:  A pseudo code that reads the data from user until dummy value 999 encountered and print some results based on this data.  //MAIN MODULE  CREATE CHILDREN_RECORD   CREATE object for CHILDREN_RECORD   COMPUTE_ INITIALIZE_VARIABLES  COMPUTE_INPUT_CHILDREN_DATA  COMPUTE_FAMILY_WITH_ZERO_CHILDREN  COMPUTE_ FAMILY_WITH_MORE_THAN_FOUR_CHILDREN  COMPUTE_ FAMILY_WITH_LARGEST_CHILDREN  COMPUTE_DISPLAY_ALL_RECORDS  END  //INITIALIZATION MODULE  CREATE INITIALIZE_VARIABLES  DECLARE and INITIALIZE MEMORY TO ARRAY CHILDREN_DATA [ ]  INITIALIZE an integer I to value 1  INITIALIZE an integer J to value 1  INITIALIZE an integer CLOCK to value 0  INITIALIZE an integer ZERO_CHILDREN to value 0  INITIALIZE an integer MORE_THAN_FOUR_CHILDREN to value 0  INITIALIZE CHILDREN_DATA [I] to value 0  END  //INPUT MODULE  CREATE INPUT_CHILDREN_DATA   WHILE CHILDREN_DATA [I] is not equal to 0 //Ensures validation   READ CHILDREN_DATA [I]   SET CLOCK = CLOCK + 1   //Validation Check   IF (CHILDREN_DATA [I]0) OR (CHILDREN_DATA [I] is not INTEGER)   PRINT INCORRECT INPUT: ENTER POSITIVE INTEGER   //Error message printed if validation fails   END IF   SET I = I + 1   END WHILE  END  //CALCULATION MODULES  CREATE FAMILY_WITH_ZERO_CHILDREN  CALL INPUT_CHILDREN_DATA   REPEAT   IF (CHILDREN_DATA [I] is equal to 0)   SET ZERO_CHILDREN = ZERO_CHILDREN = 1   END IF   UNTIL I is equal to P //Auto increments value of Iand checks the condition  END  CREATE FAMILY_WITH_MORE_THAN_FOUR_CHILDREN  CALL INPUT_CHILDREN_DATA  REPEAT   IF (CHILDREN_DATA [I]  4)  MORE_THAN_FOUR_CHILDREN = MORE_THAN_FOUR_CHILDREN + 1   END IF   UNTIL I is equal to P //Auto increments value of I and checks the condition  END  CREATE FAMILY_WITH_LARGEST_CHILDREN  CALL INPUT_CHILDREN_DATA  INITIALIZE an integer MAX to value CHILDREN_DATA [1]  REPEAT   IF (CHILDREN_DATA [I]  MAX)   Set MAX = CHILDREN_DATA [I]   END IF   UNTIL I is equal to P //Auto increments value of I and checks the condition  END  //OUTPUT MODULE  CALL FAMILY_WITH_ZERO_CHILDREN  CALL FAMILY_WITH_MORE_THAN_FOUR_CHILDREN  CALL FAMILY_WITH_LARGEST_CHILDREN  CREATE DISPLAY_ALL_RECORD   PRINT ZERO_CHILDREN   PRINT MORE_THAN_FOUR_CHILDREN   PRINT MAX  END    HIERARCHY CHART      Defining Diagram          Input      Processing      Output          READ INPUT 1      PROCESS ALL VALUES READ      Display number of families with zero children          READ INPUT 2      If INPUT is invalid display error message and read INPUT again      Display number of families with more than four children          READ INPUT 3      EVALUATE numbers of families with ZERO children      Display largest number of a children in a family          .      EVALUATE numbers of families with more than four children                .      EVALUATE largest number of children that exists in a family                UNTIL INPUT=999                          REFERENCES  Paul, R. (2015). Critical Thinking: How to Prepare Students for a Rapidly Changing World. Foundation for Critical Thinking.  Radford, B. (2013). Media Mythmakers: How Journalists, Activists, and Advertisers Mislead Us. Prometheus Books    
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.