Output the total, the average, the smallest and the largest of the list.
Note: The exact amount of numbers to be entered may vary.
Test the pseudocode using the data in the test table.
-
Write pseudocode that will add up some numbers entered by the user and print out the total. The numbers can be of any type. Start by asking the user how many numbers s/he has. Then read in the numbers one at a time. Each time you read a number, add it to a variable named, for example, total. Your design should allow a user to use it as many times as s/he wishes and to terminate if the user replies “n” when asked if /she wishes to have another go or when s/he gives a zero (0) as a value when asked of how many numbers wishes to enter. Here is what the program might look like when it is run, with the user's input shown in red:
Hi! I will add up some numbers for you.
How many numbers do you have? 4
Enter your numbers one at a time, pressing return after each number:
17.32
-3
112.011
27.9
The sum of your numbers is: 154.231
Would you like another go? (y or n) Press Return
y
Hi! I will add up some numbers for you.
How many numbers do you have? 0
Bye Bye and thank you!
Test the pseudocode using the data in the test table
- Write pseudocode for the following scenario: To count the number of times it takes player2 to guess a number between 1 and 100 that is input by player1. When the guess is high or low, display an appropriate message. When a correct guess is made, display an appropriate message and the number of guesses taken.
Test the pseudocode using the data in the test table
- Given an array with the following values:
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
5 7 20 33 44 46 48 99 101 102 105
- How many comparisons does it take using a sequential search to find the following values or determine that the item is not in the list? Explain your answer.
- How many comparisons does it take using a binary search to find the following values or determine that the item is not in the list? Explain your answer.
-
List and describe the testing strategies in the software development process. Describe in some detail and using examples 3 testing techniques. You will need to research books and/or journals in the library.
Example of presentation of your results
Suppose you were asked to write pseudocode for a program, which has to read a number, say n (which denotes that every time is different) and then print the average of all digits between n and 1.
IPO Diagram
Control Structures
- A FOR loop to control the repetition
- An IF statement to determine if an error message is to be displayed
PSEUDOCODE
Set sum to zero
Prompt for number
Get number
IF (number <= 1) then
Display “Invalid number..Stop”
Else
For counter= 1 to number
Sum=sum+counter
End For
Display “The average is = “ sum/number
End IF
DESK TESTING
Test Data 1: number is 5
Test Data 2: number is 2
Test Data 3: number is 1
Test Data 4: number is 0
Expected Results for Test Data 1 : The average is = 3
Expected Results for Test Data 2: The average is = 1.5
Expected Results for Test Data 3: Invalid number…Stop
Expected Results for Test Data 4: Invalid number …Stop