Test Plan 4

.docx

School

University of Maryland, University College *

*We aren’t endorsed by this school

Course

115

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

5

Uploaded by DirtyMoe

Test Plan 4 Kaleb Miranda 19Sep23 Project 1 Pseudocode: 1. Create a Scanner object to read input from the user. 2. Initialize variables: positiveCount = 0, negativeCount = 0, total = 0. 3. Prompt the user to enter an integer; input ends if it's 0. 4. Enter a loop: a. Read the 'number' entered by the user. b. If 'number' is greater than 0, increment 'positiveCount'. c. If 'number' is less than 0, increment 'negativeCount'. d. Add 'number' to 'total'. e. Repeat the loop until 'number' is 0. 5. If (positiveCount + negativeCount) is 0: a. Display "No numbers are entered except 0." 6. Else: a. Calculate 'average' as total / (positiveCount + negativeCount). b. Display "The number of positives is", positiveCount. c. Display "The number of negatives is", negativeCount. d. Display "The total is", total. e. Display "The average is", average. 7. Close the Scanner object. Flowchart:
Test plan: Mixed Numbers : Input: 5, -3, 0 Expected Output: The number of positives is 1 The number of negatives is 1 The total is 2 The average is 1.0 All Positive Numbers : Input: 7, 12, 5, 0 Expected Output: The number of positives is 3 The number of negatives is 0 The total is 24 The average is 8.0 All Negative Numbers : Input: -2, -8, -1, 0 Expected Output: The number of positives is 0 The number of negatives is 3 Start Create scanner object, int ---positivecount, negativecount, total Prompt for and read 'number' then enter a loop: read number if number > 0 positive if number < 0 negative add number to total repeat loop if pos+neg == 0 display "No numbers are entered except 0" Else calc avg and display all outcomes Close scanner object END
The total is -11 The average is -3.6666666666666665 No Numbers Entered Except 0 : Input: 0 Expected Output: No numbers are entered except 0 Single Positive Number : Input: 42, 0 Expected Output: The number of positives is 1 The number of negatives is 0 The total is 42 The average is 42.0 Project 6 Psuedocode: 1. Create a Scanner object to read input from the user. 2. Prompt the user to enter the first 12 digits of an ISBN-13 as a string. 3. Read 'isbn12' from the user. 4. If the length of 'isbn12' is not 12 or 'isbn12' contains non-digit characters, then: a. Display "isbn12 is an invalid input." 5. Else, call the function isValidISBN12(isbn12) to check if 'isbn12' contains only digits: a. If isValidISBN12 returns false, then: - Display "isbn12 is an invalid input." b. Else, calculate the checksum digit by calling calculateChecksum(isbn12). c. Append the checksum digit to 'isbn12' to create 'isbn13'. d. Display "The ISBN-13 number is " + isbn13. 6. Close the Scanner object. Flowchart:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help