5-2 PROJECT 1 FLOW CHART PORTION
.pdf
keyboard_arrow_up
School
Southern New Hampshire University *
*We aren’t endorsed by this school
Course
205
Subject
Computer Science
Date
Apr 3, 2024
Type
Pages
1
Uploaded by DeaconCaterpillar4154
UserGuess = Get next input
//beginning the for loop for counting the hardboiled eggs and raw eggs
i=1
Start
//obtaining the players guess
Put "Let's play! There are 12 eggs in a basket. Some eggs are raw and some eggs are hardboiled.How many are hardboiled?(0-12)" to output i < 13
TRUE
FALSE
NumGen = RandomNumber (0,1)
i = i + 1
NumGen == 1
TRUE
FALSE
Put "egg" to output
put i to output
Put " is hardboiled. \n" to output
HardBoiled = HardBoiled + 1
//Begin else loop for raw eggs Put "Egg" to output
put i to output
Put " raw \n" to output
EggCount = EggCount + 1
//End loop for counting hardboiled eggs and display total hardboiled eggs Put "Total number of hardboiled eggs is " to output
put hardBoiled to output
Put ".\n" to output
/
/Begin second loop to decide if they win or lose
UserGuess == hardBoiled
TRUE
FALSE
Put "\n You Win!" to output
Put "\n You Lose!"" to output
END
CS 205 Foundations of Software Development
Megan Miller
5-2 Project 1 Flow Chart Due 2/11/2023 at 11:59 PM
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
A semicolon (;) is necessary at the end of which type of the loop?
All loops
do-while
while
for
arrow_forward
What is the number of times the following loop is executed?
for the value of b in (1,10):
a printout of b
arrow_forward
Create a class name AddAgain for do-while loop that asks the user to enter two The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate.
arrow_forward
option 3 is incorrect
arrow_forward
Question #3:
Write a program that asks the user to enter an integer number and checks whether the number is prime or not.
Hint: A prime number (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37...) is a natural number greater than I that has no positive
divisors other than 1 and itself. To check if a number N is prime, divide it in a loop from 2 to N-1 for remainder. If
remainder is never 0, then N is prime. For example, 23 and 47 are prime, but 12 and 27 are not.
arrow_forward
Write a for loop that repeats seven times, asking the user to enter a number. The loop should also calculate the sum of the numbers entered and display the final sum.
Write a for loop that displays the following set of numbers:
0, 10, 20, 30, 40, 50 . . . 1000
What’s the initialization step?
The Boolean test/condition?
Update action/incrementation?
Convert the while loop in the following code segment to a for loop:
int count = 0;
while (count < 50) {
System.out.println("count is " + count);
count++;
}
please solve three of them
arrow_forward
Make a Craps game with the following guidelines:
import random
money = 100
Ask user if they want to play or "QUIT" (.upper())
while game !="QUIT":
2 dice generate random numbers 1-6 on each (generate random
numbers inside while loop)
Every roll cost $3
Win $5 if total is7
Win $10 for snake eyes
Else display " Craps"
Ask user if they want to play or"QUIT"
if money<3
game ="QUIT"
Print money
arrow_forward
Write a loop that runs 10 times. Note: You are not required to put anything inside the loop body.
arrow_forward
Control Loops:
A high school 1000 students and 1000 lockers. The principal plays the following game: She asks dthe first student to open all the lockers. Shen then asks the second student to close all the even-numbered lockers. The third student is asked to check every third locker. If it is open, the student closes it; if it is closed, the student opens it. The remaining students continue this game . In general, the nth student checks every nth locker. If the locker is open, the student closes it; if it is closed, the student opens it. After all the students have taken their turns, some of the lockers are open and some are closed. Write a program thatprompts the user to enter the number of lockers in a school. After the game is over, the program outputs the number of lockers and the locker numbers of the lockers that are open. Test run your program for the following inputs: 1000, 5000, 10,000. Do you see any pattern developing for the locker numbers that are open in the output?…
arrow_forward
Question #3:
Write a program that asks the user to enter an integer number and checks whether the number is prime or not.
Hint: A prime number (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 . .) is a natural number greater than 1 that has no positive
divisors other than 1 and itself. To check if a number N is prime, divide it in a loop from 2 to N-1 for remainder. If
remainder is never 0, then N is prime. For example, 23 and 47 are prime, but 12 and 27 are not.
Question #4:
Re-write the program of Question #3 using data files. The input data numbers.txt contains (positive) integer
numbers. Each time the program reads a number, check whether it is a prime and stores the result in the
output file Results.txt.
373
373 is Prime!!
11 is Prime!!
2552 is NOT prime!!
5 is Prime!!
3561 is NOT prime!!
11
2552
3561
numbers.txt
Results.txt
End of Homework #2 ====
Page 7 of 7
arrow_forward
Loop that will allow for one complete round of hangman and if the word is guessed correct letter by letter the gallows shows the hangman
arrow_forward
You need to write a loop that will repeat exactly 125 times. Which is the preferred loop construct to use?
A.
while
B.
do while loop
C.
for loop
arrow_forward
Part A: While Loop Program - using Java.
Write a program that detects Fibonacci numbers. Prompt the user to input a positive integer. Upon input, the program will determine if the number is either a Fibonacci number or not. If a Fibonacci number, then the order of the number in the sequence must be output. If not a Fibonacci number, then the Fibonacci numbers above and below it (including their order in the sequence) must be output. Once it finishes, the program will prompt the user for a new number. The program will exit if the user enters a non-integer number or string (such as “quit”) instead of an integer. Use the sample output file, fib-seq-det.txt, to view a sample session
Additionally:
For both the above problems, the first four numbers of the Fibonacci sequence are: 0, 1, 1, and 2.
Part A must use While loops only
arrow_forward
Question#2. The distance a vehicle travels can be calculated as fallout:
Distance = Speed * Time
For example, if a train travels 60 miles-per-hour for three hours, the distance [raveled is 120
miles. Write a program that asks for the speed of a vehicle (in miles-per-hour) and the
number of hours it has traveled. It should use a loop to display the distance a vehicle has
traveled for each hour of a time period specified by the user. For example, if a vehicle is
traveling at 40 mph far a three-hour time period, it should display a report similar to the one
chat follows:
Hour
Distance Traveled
1
90
2
100
3
150
Input Validation: Do not accept a negative number for speed and do not accept any value les
than 1 for time traveled.
arrow_forward
Q2: Write a program that reads in a series of integer numbers, and determines how many positive odd
numbers are among them. Numbers are read until a negative integer is given. Use DO-Loop with
EXIT statement.
arrow_forward
i=10; for (int x=5; x
arrow_forward
Programming is Java
arrow_forward
Class Exercise
Write a program that asks the user to enter how
many students they have. Use a for loop to
iterate through each student. For each student,
allow the user to enter as many scores as they
want and let them know that entering -1 will
indicate the end of entering scores (note: use a
while loop with sentinel value). Sum all the
scores for each student and display the total on
the screen. For example:
Student 1 Total score is 340
Student 2 Total score is 200
arrow_forward
6. If there is a cycle:
for ( int i=0; i<=5;i++)
{
i++;
}
How many times will the loop body be executed?
А. О
B. 3 times
C. 5 times
D. 6 times
arrow_forward
write a for loop that displays each integer number from 14 to 25 (inclusive) . include any necessary declarations
arrow_forward
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the
sequence. Create a for loop that compares each character of the two strings. For each matching character, add one point to
user_score. Upon a mismatch, end the loop.
Sample output with inputs: 'RRGBRYYBGY' 'RRGBBRYBGY'
User score: 4
Code writing challenge activity demo
461710.3116374.qx3zqy7
1 user_score = 0
2 simon_pattern
3 user_pattern
3456
4
TTV
=
=
input()
input()
5 Your solution goes here ""'
6
7 print (f'User score: {user_score}')
F
F
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
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- A semicolon (;) is necessary at the end of which type of the loop? All loops do-while while forarrow_forwardWhat is the number of times the following loop is executed? for the value of b in (1,10): a printout of barrow_forwardCreate a class name AddAgain for do-while loop that asks the user to enter two The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate.arrow_forward
- option 3 is incorrectarrow_forwardQuestion #3: Write a program that asks the user to enter an integer number and checks whether the number is prime or not. Hint: A prime number (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37...) is a natural number greater than I that has no positive divisors other than 1 and itself. To check if a number N is prime, divide it in a loop from 2 to N-1 for remainder. If remainder is never 0, then N is prime. For example, 23 and 47 are prime, but 12 and 27 are not.arrow_forwardWrite a for loop that repeats seven times, asking the user to enter a number. The loop should also calculate the sum of the numbers entered and display the final sum. Write a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 . . . 1000 What’s the initialization step? The Boolean test/condition? Update action/incrementation? Convert the while loop in the following code segment to a for loop: int count = 0; while (count < 50) { System.out.println("count is " + count); count++; } please solve three of themarrow_forward
- Make a Craps game with the following guidelines: import random money = 100 Ask user if they want to play or "QUIT" (.upper()) while game !="QUIT": 2 dice generate random numbers 1-6 on each (generate random numbers inside while loop) Every roll cost $3 Win $5 if total is7 Win $10 for snake eyes Else display " Craps" Ask user if they want to play or"QUIT" if money<3 game ="QUIT" Print moneyarrow_forwardWrite a loop that runs 10 times. Note: You are not required to put anything inside the loop body.arrow_forwardControl Loops: A high school 1000 students and 1000 lockers. The principal plays the following game: She asks dthe first student to open all the lockers. Shen then asks the second student to close all the even-numbered lockers. The third student is asked to check every third locker. If it is open, the student closes it; if it is closed, the student opens it. The remaining students continue this game . In general, the nth student checks every nth locker. If the locker is open, the student closes it; if it is closed, the student opens it. After all the students have taken their turns, some of the lockers are open and some are closed. Write a program thatprompts the user to enter the number of lockers in a school. After the game is over, the program outputs the number of lockers and the locker numbers of the lockers that are open. Test run your program for the following inputs: 1000, 5000, 10,000. Do you see any pattern developing for the locker numbers that are open in the output?…arrow_forward
- Question #3: Write a program that asks the user to enter an integer number and checks whether the number is prime or not. Hint: A prime number (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 . .) is a natural number greater than 1 that has no positive divisors other than 1 and itself. To check if a number N is prime, divide it in a loop from 2 to N-1 for remainder. If remainder is never 0, then N is prime. For example, 23 and 47 are prime, but 12 and 27 are not. Question #4: Re-write the program of Question #3 using data files. The input data numbers.txt contains (positive) integer numbers. Each time the program reads a number, check whether it is a prime and stores the result in the output file Results.txt. 373 373 is Prime!! 11 is Prime!! 2552 is NOT prime!! 5 is Prime!! 3561 is NOT prime!! 11 2552 3561 numbers.txt Results.txt End of Homework #2 ==== Page 7 of 7arrow_forwardLoop that will allow for one complete round of hangman and if the word is guessed correct letter by letter the gallows shows the hangmanarrow_forwardYou need to write a loop that will repeat exactly 125 times. Which is the preferred loop construct to use? A. while B. do while loop C. for looparrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education