Test Plan 4
.docx
keyboard_arrow_up
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
Related Questions
A for statement is a loop that goes through a list of things. Therefore, it keeps running as long as there are objects to process. Is this a true or a false statement?
arrow_forward
Python programming
Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number.
TY!
arrow_forward
Lap Timer Tool
Write a program ON PYTHON that asks the user to enter the number of times that they have run around a racetrack, and then uses a loop to prompt them to enter the lap time for each of their laps. When the loop finishes, the program should display the time of their fastest lap, the time of their slowest lap, and their average lap time.
arrow_forward
Task 2: Multiples
Write a program that asks the user for an integer n, and then prints first 10 multiples of that integer. Use a
while/do...while loop.
Example:
Enter an integer: 2
Output:
2 x 1 = 2
2 x 2 = 4
2 х 3 %3D 6
2 x 4 = 8
2 x 5
= 10
12
2 х6
2 x 7
2 х8
14
16
2 x 9
18
2 x 10 =
20
arrow_forward
Basic while loop expression.
Write a while loop that prints userNum divided by 4 (integer division) until reaching 2 or less. Follow each number by a space. Example output for userNum = 160:40 10 2 Note: These activities may test code with different test values. This activity will perform four tests, with userNum = 160, then with userNum = 8, then with userNum = 0, then with userNum = -1. See "How to Use zyBooks".Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.
arrow_forward
Programming is Java
arrow_forward
Unlabeled Break:
Create a Java program that uses a "while" loop to output the numbers from 1 to 10 to the console.
Add an "if" statement inside the loop to check if the number being outputted is greater than 5. If it is, use a "break" statement to exit the loop.
Labeled Break:
Create a Java program that uses a labeled "for" loop to output the numbers from 1 to 5, followed by the letters A to C to the console.
Add an "if" statement inside the loop to check if the number being outputted is greater than 3. If it is, use a labeled "break" statement to exit the loop completely.
arrow_forward
True or False: The do-while loop is a pretest loop, as opposed to a main loop.
arrow_forward
1.Complete Steps 1-7 in the comments below. The remaining comments explain the logic. Customers can check a variety of loans and interest rates. When finished, type quit
# Step 1: add an input statement to enter name or type quit to exit
# Step 2: add a while loop to keep asking for a name until the user types quit
# Step 3: declare two variables for loan and interest, like months below, # convert them to float, and ask the user to input their values to the screen.
months = float(input("How many months will it take to repay your loan? "))
print("***************************************************************") print (name, "you requested an estimate on a loan for {0:.2f}" .format(loan))
# Step 4: add a print statement to display the interest and # of months
print("*******************************************************************************") print("Here are the rates for simple interest, compound interest, and monthly interest", "\n")…
arrow_forward
Programming Language: Java
Direction: Use the do while loop statement to display the same given output below.
Output:
1. Jose
2. Jose
3. Jose
4. Jose
5. Jose
arrow_forward
• Exercise # 2: Write a loop that reads numbers from the user and sum them. The loop continues till a negative number is entered. Your program then prints
the result.
• The following are sample runs of the program.
Sample run 1:
Enter a positive number: (or a negative value to finish):5
Enter a positive number: (or a negative value to finish):2
Enter a positive number: (or a negative value to finish):4
Enter a positive number: (or a negative value to finish):-5
Sum = 11.0
Sample run 2:
Enter a positive number: (or a negative value to finish):-8
No positive number was entered.
arrow_forward
Lap Timer Tool
Write a Python (GUI program) that asks the user to enter the number of times that they have run around a racetrack, and then uses a loop to prompt them to enter the lap time for each of their laps. When the loop finishes, the program should display the time of their fastest lap, the time of their slowest lap, and their average lap time.
arrow_forward
1_ Write a program that reads a character and prints it only if it is 'y' or 'Y' (Simulation of If-Else then structure).
2_Write a program that prints the odd numbers between 1 and 10 using loop (Number 1 ASCII code is 49).
arrow_forward
PYTHON:
The following code causes an infinite loop. Can you figure out what is incorrect?
def test_code(num):
x = num
while x % 2 == 0:
x = x / 2
test_code(0)
When called with 0, it triggers an infinite loop
The modulo operator is used incorrectly
Missing an else statement
Missing the continue keyword
arrow_forward
Instructions
Objectives:
Use a while loop
Use multiple loop controlling conditions
Use a boolean method
Use the increment operator
Extra credit: Reuse earlier code and call two methods from main
Details:This assignment will be completed using the Eclipse IDE. Cut and paste your code from Eclipse into the Assignment text window.
This is another password program. In this case, your code is simply going to ask for a username and password, and then check the input against four users. The program will give the user three tries to input the correct username-password combination.
There will be four acceptable user-password combinations:
alpha - alpha1
beta - beta1
gamma - gamma1
delta - delta1
If the user types in one of the correct username-password combinations, then the program will output: “Login successful.” Here are a couple of example runs (but your code needs to work for all four user-password combinations):
Username: betaType your current password: beta1Login…
arrow_forward
True/False 1. The best way to write a program is to immediately type in some code and then debug it until it works.
arrow_forward
Exercise # 8 – Student Number Password
Description of the Problem
Write a program that inputs your student number and printout your Biography when the student number
is correct. Use a Do While / While loop to repeat the process when an incorrect student number is placed.
Sample Output
Enter your student no. : 29766512
Name : Lastname, Firstname MI
Course : [your course here]
Favorite [write something here]: [your favorite 1]
Favorite [write something here] : [your favorite 2]
Favorite quotation : "quotation here"
Enter your student no. : 88888888
"Incorrect Student No.!!"
Note : Template will not be available for this one. As the code is very short to finish the exercise.
arrow_forward
assembly language please with comment and screen shot of the out put
arrow_forward
Write the pseudocode for a program that will continue prompting a user for a value
whilst the total of all values remains less than 100. The program must keep track of
the number of times the loop executes and displays the number of times the loop
executed at the end of the program.
arrow_forward
pow(3,4)=?
Select one:
O a. 81
O b. 12
c.
64
O d. 7
arrow_forward
1. Squares
Looping random numbers and manipulating those values are fun, too! Why don't we try one that returns the square of an inputted number repeatedly until the user inputs 0? Let's do this!
Instructions:
Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.
Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.
Input
Multiple lines containing an integer.
2
6
0
Output
Multiple lines containing an integer.
4
36
0
_USED JAVA PROGRAMMING LANGUAGE
arrow_forward
Alert dont submit AI generated answer.
arrow_forward
python simple code
arrow_forward
Text Rectangle. Create a program that draws a rectangle in text mode given the dimensions provided by the user. Attached is a sample of the execution of the program.
Hint: Use a loop and the repetition operator to create the rectangle.
arrow_forward
True or False: The do-while loop is a pretest loop.
arrow_forward
Sample output
This is from one continuous run of the program.
Please enter a product name. You can also enter x to quit: laptop
Please enter the product's category: tech
Please enter the product's price: 100
The new SKU is LAP and the new price is 110.00000000000001
Please enter a product name. You can also enter x to quit: scantron
Please enter the product's category: office
Please enter the product's price: .75
The new SKU is RON and the new price is 0.8250000000000001
Please enter a product name. You can also enter x to quit: whiteboard cleaner
Please enter the product's category: other
Please enter the product's price: 8
The new SKU is WHITEBOARD CLEANER and the new price is 8.8
Please enter a product name. You can also enter x to quit: x
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Related Questions
- A for statement is a loop that goes through a list of things. Therefore, it keeps running as long as there are objects to process. Is this a true or a false statement?arrow_forwardPython programming Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number. TY!arrow_forwardLap Timer Tool Write a program ON PYTHON that asks the user to enter the number of times that they have run around a racetrack, and then uses a loop to prompt them to enter the lap time for each of their laps. When the loop finishes, the program should display the time of their fastest lap, the time of their slowest lap, and their average lap time.arrow_forward
- Task 2: Multiples Write a program that asks the user for an integer n, and then prints first 10 multiples of that integer. Use a while/do...while loop. Example: Enter an integer: 2 Output: 2 x 1 = 2 2 x 2 = 4 2 х 3 %3D 6 2 x 4 = 8 2 x 5 = 10 12 2 х6 2 x 7 2 х8 14 16 2 x 9 18 2 x 10 = 20arrow_forwardBasic while loop expression. Write a while loop that prints userNum divided by 4 (integer division) until reaching 2 or less. Follow each number by a space. Example output for userNum = 160:40 10 2 Note: These activities may test code with different test values. This activity will perform four tests, with userNum = 160, then with userNum = 8, then with userNum = 0, then with userNum = -1. See "How to Use zyBooks".Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.arrow_forwardProgramming is Javaarrow_forward
- Unlabeled Break: Create a Java program that uses a "while" loop to output the numbers from 1 to 10 to the console. Add an "if" statement inside the loop to check if the number being outputted is greater than 5. If it is, use a "break" statement to exit the loop. Labeled Break: Create a Java program that uses a labeled "for" loop to output the numbers from 1 to 5, followed by the letters A to C to the console. Add an "if" statement inside the loop to check if the number being outputted is greater than 3. If it is, use a labeled "break" statement to exit the loop completely.arrow_forwardTrue or False: The do-while loop is a pretest loop, as opposed to a main loop.arrow_forward1.Complete Steps 1-7 in the comments below. The remaining comments explain the logic. Customers can check a variety of loans and interest rates. When finished, type quit # Step 1: add an input statement to enter name or type quit to exit # Step 2: add a while loop to keep asking for a name until the user types quit # Step 3: declare two variables for loan and interest, like months below, # convert them to float, and ask the user to input their values to the screen. months = float(input("How many months will it take to repay your loan? ")) print("***************************************************************") print (name, "you requested an estimate on a loan for {0:.2f}" .format(loan)) # Step 4: add a print statement to display the interest and # of months print("*******************************************************************************") print("Here are the rates for simple interest, compound interest, and monthly interest", "\n")…arrow_forward
- Programming Language: Java Direction: Use the do while loop statement to display the same given output below. Output: 1. Jose 2. Jose 3. Jose 4. Jose 5. Josearrow_forward• Exercise # 2: Write a loop that reads numbers from the user and sum them. The loop continues till a negative number is entered. Your program then prints the result. • The following are sample runs of the program. Sample run 1: Enter a positive number: (or a negative value to finish):5 Enter a positive number: (or a negative value to finish):2 Enter a positive number: (or a negative value to finish):4 Enter a positive number: (or a negative value to finish):-5 Sum = 11.0 Sample run 2: Enter a positive number: (or a negative value to finish):-8 No positive number was entered.arrow_forwardLap Timer Tool Write a Python (GUI program) that asks the user to enter the number of times that they have run around a racetrack, and then uses a loop to prompt them to enter the lap time for each of their laps. When the loop finishes, the program should display the time of their fastest lap, the time of their slowest lap, and their average lap time.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,