image
.jpg
keyboard_arrow_up
School
Boston University *
*We aren’t endorsed by this school
Course
112
Subject
Computer Science
Date
Apr 26, 2024
Type
jpg
Pages
1
Uploaded by SuperMosquitoMaster740 on coursehero.com
—— PLTW Computer Science Principles - Unit 1 Activity 1.2.1 - Catch-a-Turtle Steps 26 - 50 Provide the definitions of the vocabulary woh‘s below. \ Global variable \ It is visible throughout the whole program 7 | | \ | | | Game Requirements - Part 1, Steps 26 - 50 1. The click should trigger the player's score to accumulate If the timer runs out before the turtle is clicked, the turtle will disappear and the M 2 game will display a message. Display a Score 27. Observe the code sample below and follow the instructions in the comments. Write your observations in the space helow the code editor. B
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
Computer Science
Godot Programming
Programming Problem 1. Rock, Paper, Scissors This is your traditional rock-paper-scissors game, where two players select one of the three options and a result is produced based on their selection. For reference: Rock beats scissors Paper beats rock Scissors beats paper For this problem, you are to assume that two human players will play against each other and will input their choices accordingly. The input for each player will be in the form of buttons. Once a player clicks on a button, the rest of their buttons are locked in place (i.e. disabled). Once the other player selects their pick, the program outputs who won or if there was a draw. This isn’t exactly the most realistic way to code the game as it would be better if both players made their choice at the same time, but we’ll just have to chalk this up as a limitation for our exam. Aside from the game itself, the program should track the score of each player. Basically, if one wins, that…
arrow_forward
Programming Language: C++
Develop a Tic Tac Toe game that will match a player against the computer.
Do’s:
Use a typical 3 x 3 board. The horizontal axis should be labeled A, B, C. The vertical axis should be labeled 1, 2, 3. For Example: the attatched picture.
Use User-Defined Functions.
Use Branching.
Use Loops.
Use String functions.
Randomly determine who will move first, the human or computer.
Assign O to the computer and X to the Human player.
Ask the user to select their move using the horizontal and vertical position. For example: A1 for the upper left square, or B2 for the center square.
After each move, redraw the board with the X’s and O’s in the right positions.
After each game, ask the user if they want to play again. If they do, start the game again.
Do not’s:
Don’t use User Classes or Objects
Don’t use images
arrow_forward
Case Study – Finding Factors
Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example,
when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50;
when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60
when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150
User should be able to repeat procedure as many times as they like.
Write and test the module that reads a positive and non-zero integer.
arrow_forward
Case Study – Finding Factors
Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example,
when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50;
when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60
when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150
User should be able to repeat procedure as many times as they like.
Write and test the process or module in C++ that allows the user to repeat this process as many times as the person wanted.
arrow_forward
Case Study – Finding Factors
Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example,
when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50;
when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60
when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150
User should be able to repeat procedure as many times as they like.
Determine the best control structures to use in the solution for reading program input(s). You must provide explanation for your answers.
arrow_forward
Case Study – Finding Factors
Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example,
when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50;
when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60
when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150
User should be able to repeat procedure as many times as they like.
Determine program input(s). Provide a brief explanation for your answer.
arrow_forward
Case Study – Finding Factors
Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example,
when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50;
when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60
when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150
User should be able to repeat procedure as many times as they like.
To represent the hierarchical structure of modules, create a structure chart with data flow and conditional and loop execution. It should be noted that the hierarchical structure of modules should be designed with appropriate and manageable sized functions.
arrow_forward
Case Study – Finding Factors
Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example,
when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50;
when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60
when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150
User should be able to repeat procedure as many times as they like.
Create a flowchart for the module that processes the integer and prints out all of its factors in ascending order to show the process's execution flow.
arrow_forward
Case Study – Finding Factors
Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example,
when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50;
when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60
when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150
User should be able to repeat procedure as many times as they like.
In C++ program, write and test the module that processes the integer and print out all its factors in ascending order.
arrow_forward
Problem Description
The hailstone sequence is defined as the integer sequence that results from manipulating a positive
integer value n as follows:
If n is even, divide it by 2 (using floor division)
• If n is odd, multiply it by 3 and then add 1
Repeat this process until you reach 1.
For example, starting with n = 5, we get the sequence 5, 16, 8, 4, 2, 1.
If n is 6, we get the sequence 6, 3, 10, 5, 16, 8, 4, 2, 1.
If n is 7, we get 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1.
If n is 8, we get the sequence 8, 4, 2, 1.
As far as anyone can tell, this process will eventually reach 1 for any starting value, although
mathematicians have been unable to formally prove this property as of yet.
a. Write a Python function named hail () that takes a single integer argument. hail() should
print out the sequence of numbers generated by applying the process above to the function
parameter. This function does not return any value.
arrow_forward
Programming Problem 3 – Broken GPS
Consider yourself driving with 60 miles/hour in a city that has only grid like streets, and your GPS is broken.
The specifications of the problem are:
• With (x, y) as the coordinates of the car, consider the initial position (0,0).
• At each intersection, the only directions available are North, South, East or West
• The GPS is broken, and it chooses the direction randomly at each intersection, which happens every 5 minutes
• The assumption is that the car has the same speed at all times, including when it changes direction and turns.
Write a program that calculates the direct distance from the initial point to the location point of the driver after one hour of driving (i.e. the distance between two points).
Java Progra
arrow_forward
Python Turtle Graphics
Draw a spiral diagram using Python turtle package program follows 3 steps:
Import the turtle module
Create a turtle to control.
Draw around using the turtle methods.
You should consider the following points in your solution:
The shapes should be drawn with the shown colors
Yellow and white for the square-like shapes.
Blue for the background.
The prompt should have a turtle shape.
The number of iterations should be 300
You should use only one loop.
The number of the yellow color lines should be 200.
The final shape of the output should be as shown in the picture attached.
Make sure to set properly the starting position (x & y) of your drawing, to maintain the required diagram.
video on youtube:
https://www.youtube.com/watch?v=ZqoJD2RMu1I
arrow_forward
C++ programming
It has been observed by management that some faculty member at the university demonstrates a lackadaisical attitude toward work. They seldom go to class yet at the end of each month they receive full salary. Management has decided that GHs 200, 300, 400, and 500 will be deducted from a faculty’s salary if he/she offends once, twice, third time and forth time respectively in a month. This means that if a faculty member offends once in a month GHs 200 will be deducted, if a faculty member offends twice in a month, GHs 500 (i.e. 200+300) will be deducted, if a faculty member offends three times in a month GHs 900 (i.e.200+300+400), will be deducted and if a faculty member offends four times in a month GHs 1,400 (i.e. 200+300+400+500). Assuming all faculty members are on a flat salary rate of GHs 2500.
a. Write a program to request for the names of four faculty members and number times he/she has absented him/herself from class. One of them should have absented him/herself…
arrow_forward
C# Code:
There are two A, B players playing the game. Player A is angry with him, and player B is angry with
him. Both s and t include only small English letters and are of equal length. A makes the first move,
then B, then A, and so on. Before the start of the game, players are familiar with the content of both
the letter s and t characters. These players form one rope during the game. Initially, the character
unit w is empty. In each move, the player removes any single letter from the alphabetical order in
order and adds this letter any (any position) to the letter w you can add a character to any index.
Please refer to the Definitions for more specifications). If in any stage of the game, the character unit
w is more than 1 length and is a palindrome, the player who made the last move wins.
If even after the end of the game (i.e., when both s and t are empty strings), no one can make a unit
of characters w a palindrome, and then player B wins.
Given the unit of the letters s, and t,…
arrow_forward
Direction: Read each sentence/ situation carefully and select the BEST answer among the choices.
1. It is a Boolean expression that tells when the loop will exit.
2. The sequence that makes up the loop body may either be a block of Turbo C statements or a single Turbo C statement.
3. In Turbo C it is a reserved word.
4. Its values determine the number of times the loop iterates.
5. It is the second type of open-ended loop.
Condition
For Loop
Statement
For
Do while Loop
arrow_forward
Compare Numbers - Python Language please!
Programming challenge description:
Little Tommy is in kindergarten on the first day of class. His teacher has taught him about inequalities today, and he is learning how to draw crocodiles to represent them. When there are two numbers, A and B, there are three options:1. If A is greater than B, then draw '>'. The crocodile's mouth is pointed toward the bigger number, A.2. If A is less than B, then draw '<'. The crocodile faces B.3. If A is equal to B, draw '='. The crocodile is confused and keeps its mouth shut.Unfortunately, Tommy does not like to do his homework, and has bribed you to write a program to do it for him.
Input:
The input consists of two integers A and B on a line, separated by a space. |A,B| < 2^63.
Output:
Print a line containing the appropriate symbol that describes the relationship between the numbers.
Test 1
Test InputDownload Test 1 Input
35 40
Expected OutputDownload Test 1 Output
<
arrow_forward
Language C++
It has been observed by management that some faculty member at the
university demonstrates a lackadaisical attitude toward teaching. They
seldom go to class yet at the end of each month they receive full salary.
Management has decided that GHs 200, 300, 400, and 500 will be deducted
from a faculty’s salary if he/she offends once, twice, third time and forth
time respectively in a month. This means that if a faculty member offends
once in a month GHs 200 will be deducted, if a faculty member offends twice
in a month, GHs 500 (i.e. 200+300) will be deducted, if a faculty member
offends three times in a month GHs 900 (i.e. 200+300+400), will be deducted
and if a faculty member offends four times in a month GHs 1,400 (i.e.
200+300+400+500). Assuming all faculty members are on a flat salary rate of
GHs 2000.
a. Write a program to request for the names of four faculty members and
number times he/she has absented him/herself from class. One of
them should have absented…
arrow_forward
INFS3410
Practice Questions
Chapters 1, 2 and 3
The Following is an example run of an educational program for
school children. The program help kids to practice their
additions and subtraction skills.
Your task is to develop a program that can achieve the same
exact thing. Bear in mind the following important guidelines:
- The user may choose between additions and subtractions
- The user may choose the difficulty level (easy, medium,
hard)
- The program should display 5 questions and calculate the
total score
- No two questions should be the same
Please enter your name: Hafedh AlShihi
**************
Hello Hafedh AlShihi
Welcome to our Additions / Subtractions
Practice
****k*********
Which operation you want to practice? Type
1 for Additions, or Type 2 for
subtractions: 2
Please select your difficulty level
Type 1 for Easy (numbers 1 to 10)
Type 2 for Medium (numbers 10 to 100)
Type 3 for Hard (numbers 100 to 1000)
1
Here are 5 easy-level subtraction
questions, please attempt all:
How…
arrow_forward
8. A game is played by moving a game piece left or right along a horizontal game board. The board consists of
spaces of various colors, as shown. The circle represents the initial location of the game piece.
Yellow
Black
Green
Green
Red
Yellow
Black
Black
Yellow
Black
The following algorithm indicates how the game is played. The game continues until the game is either won
by landing on the red space or lost when the piece moves off either end of the board.
Step 1: Place a game piece on a space that is not red and set a counter to 0.
Step 2: If the game piece is on a yellow space, move the game piece 3 positions to the left and go to step 3.
Otherwise, if the game piece is on a black space, move the game piece 1 position to the left and go to step 3.
Otherwise, if the game piece is on a green space, move the game piece 2 positions to the right and go to step
3.
Step 3: Increase the value of the counter by 1.
Step 4: If game piece is on the red space or moved off the end of the game…
arrow_forward
Part 3: Looping
while(x<y)
{
If(z<0){
x=x+a;
}
Else{
x=x+z;
z= -z
}
x=x+1;
}
Instructor Example 1: user input: x=5, y=2, z=5, a=5
x
y
z
a
Instructor Example 2: user input: x=2, y=13, z= -1, a=4
x
y
z
a
Looping Test Case 1: user input: x=2, y=18, z=10, a=2
x
y
z
a
Looping Test Case 2: user input: x=1, y=6, z=0, a=10
x
y
z
a
arrow_forward
Assignment 1/
Reset to Starter Code
2. Problem 2: Product ID Numbers Saved
Problem Description
In this second problem, you will build on and extend the program created while solving the first problem. You will be expected to isolate both the product id number and company number from the barcode number of the item to be purchased by the customer.
Input
You will receive (from the user) the following as input (in order):
• The first and last name of the customer (e.g., Eric Poitras)
• The item to be purchased, identified through a barcode number (e.g., 1909238092)
• The cost of the item to be purchased by the customer (e.g., 8.50)
• The cash amount given by the customer (e.g., 10.00)
Processing
1. Extract the product id and company id numbers
2. Print the data stored in each variable in the corresponding format
Output
1. Customer (Last, First): {LAST} {FIRST}
2. Item Number (Product, Company): {PRODUCT} {COMPANY}
3. Item Cost: (COST}
4. Cast Amount: {CASH}
Examples
Input
Output
Eric…
arrow_forward
Crispies Bagels and Bites wants a program that allows its salesclerks to enter the number of bagels, donuts, and cups of coffee a customer orders. Bagels are 99 cents, donuts are 75 cents, and coffee is $1.20 per cup. The program should calculate and display the total price of the customer’s order. First, create an IPO chart for this problem, and then desk-check the algorithm twice. For the first desk-check, use 0, 12, and 2 as the number of bagels, donuts, and cups of coffee, respectively. For the second desk-check, use 2, 6, and 1.
arrow_forward
Task using C language
Two spacecrafts are traveling at different speeds from Earth to Mars. While spacecraft A doubles its speed every day, spacecraft B triples its speed in the same period. Given their initial speeds, your task is to determine how many days spacecraft B will take to travel faster than spacecraft A.
If the initial speed of spacecraft A is 7, it will be 14 after 1 day, 28 after 2 days, and so on.
If the initial speed of spacecraft B is 4, it will be 12 after 1 day, 36 after 2 days, and so on.
If the initial speed of spacecrafts A and B are 7 and 4, respectively, B will be faster than A after 2 days, as the speed of A will be 28 and the speed of B will be 36.
Requirements
Follow the format of the examples below.
You will be given several test cases in a single run, and you must provide an answer for all of them.
Use #define
Examples (your program must follow this format precisely)
Example #1
Number of cases: 3Speed of A: 7Speed of B: 4Case #1: 2 day(s)Speed of A:…
arrow_forward
python programming: chess - pawn movement
Input: s1, s2, x1, y1, pawn
s1,s2 - horizontal size and vertical size of the board respectively.
x1, y1 - position of pawn in the board
pawn - name of the piece. May only move 1 step at a time northward.
Output: z1, z2, z3... *see image below*
Constraints:
Board height and width range from 7 to 10 and are independent of each other.
Starting and end positions should always be within the specified size
No special moves allowed like pawn moving 2 steps ahead from second row, en passant, and castling
arrow_forward
int m =0;
while(++m < 2 )
System.out.print( m );
System.out.print( m );
a. 112233
Ob. 12
C. 123
Od. 001122
arrow_forward
2) for both triangle and diamond, first display a triangle of requested size, and then
if the choice is a diamond, add the bottom part
3) displays the shape
We want to create a program that draws a diamond or a triangle with a size that the
user selects using a specific character that will be entered at the keyboard. Here are
two examples:
To write this program, we will assume that we have the following functions:
1) void instructions()
// This function describes the program and how it works
A triangle of size 4, using *:
2) int menu()
// This function will return a choice to the main ; 1) draw triangle, 2) draw
diamond, and 3) quit
***
*****
*******
3) draw_shape(int choice)
// This function calls on appropriate function depending on the choice to draw a
shape
A diamond of size 4, using *:
4) int get_size()
// This function will return the size of the shape, same function for either of the
shapes
***
*****
*******
*****
5) char get_char()
// This function will ask users to select a…
arrow_forward
Flag question
Let A = {1, 2, 3, 4, 5, 6, 7}
Let B = {3, 4, 5, 6, 7, 8, 9}
Let X = 13
Let X=X+|An B|
Let X=X+|A U B|
What is the mystery number X?
Answer:
arrow_forward
Problem Descriptions:
In this problem, your task is to write a program to find whether a user-entered 2-D point (P) lies
(i)
(ii)
(iii)
The circles are specified using their center coordinates and radii. See the illustrations below
showing all three cases you need to consider:
within both of the two given circles,
within only one of those circles, or
outside both circles (treat a point ON a circle as being inside the circle).
Pis outside both circles
Pis inside ONLY one circle
Sample Outputs:
Sample output #1
POINT MEMBERSHIP WITHIN TWO CIRCLES
Circle 1: center at ( 6, -5 ) and radius: 3
Circle 2: center at ( 12, -7 ) and radius: 5
Please enter the x-coordinate of the test point:
8
-5
Please enter the y-coordinate of the test point:
Point lies within both circles.
Sample output #2
POINT MEMBERSHIP WITHIN TWO CIRCLES
Circle 1: center at ( 6 , -5 ) and radius: 3
Circle 2: center at ( 12 , -7 ) and radius: 5
Please enter the x-coordinate of the test point:
12
Please enter the y-coordinate…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Related Questions
- Computer Science Godot Programming Programming Problem 1. Rock, Paper, Scissors This is your traditional rock-paper-scissors game, where two players select one of the three options and a result is produced based on their selection. For reference: Rock beats scissors Paper beats rock Scissors beats paper For this problem, you are to assume that two human players will play against each other and will input their choices accordingly. The input for each player will be in the form of buttons. Once a player clicks on a button, the rest of their buttons are locked in place (i.e. disabled). Once the other player selects their pick, the program outputs who won or if there was a draw. This isn’t exactly the most realistic way to code the game as it would be better if both players made their choice at the same time, but we’ll just have to chalk this up as a limitation for our exam. Aside from the game itself, the program should track the score of each player. Basically, if one wins, that…arrow_forwardProgramming Language: C++ Develop a Tic Tac Toe game that will match a player against the computer. Do’s: Use a typical 3 x 3 board. The horizontal axis should be labeled A, B, C. The vertical axis should be labeled 1, 2, 3. For Example: the attatched picture. Use User-Defined Functions. Use Branching. Use Loops. Use String functions. Randomly determine who will move first, the human or computer. Assign O to the computer and X to the Human player. Ask the user to select their move using the horizontal and vertical position. For example: A1 for the upper left square, or B2 for the center square. After each move, redraw the board with the X’s and O’s in the right positions. After each game, ask the user if they want to play again. If they do, start the game again. Do not’s: Don’t use User Classes or Objects Don’t use imagesarrow_forwardCase Study – Finding Factors Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example, when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50; when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60 when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150 User should be able to repeat procedure as many times as they like. Write and test the module that reads a positive and non-zero integer.arrow_forward
- Case Study – Finding Factors Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example, when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50; when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60 when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150 User should be able to repeat procedure as many times as they like. Write and test the process or module in C++ that allows the user to repeat this process as many times as the person wanted.arrow_forwardCase Study – Finding Factors Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example, when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50; when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60 when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150 User should be able to repeat procedure as many times as they like. Determine the best control structures to use in the solution for reading program input(s). You must provide explanation for your answers.arrow_forwardCase Study – Finding Factors Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example, when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50; when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60 when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150 User should be able to repeat procedure as many times as they like. Determine program input(s). Provide a brief explanation for your answer.arrow_forward
- Case Study – Finding Factors Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example, when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50; when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60 when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150 User should be able to repeat procedure as many times as they like. To represent the hierarchical structure of modules, create a structure chart with data flow and conditional and loop execution. It should be noted that the hierarchical structure of modules should be designed with appropriate and manageable sized functions.arrow_forwardCase Study – Finding Factors Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example, when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50; when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60 when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150 User should be able to repeat procedure as many times as they like. Create a flowchart for the module that processes the integer and prints out all of its factors in ascending order to show the process's execution flow.arrow_forwardCase Study – Finding Factors Create a solution with functions (modules) and control structures for a program that reads a positive and non-zero integer entered by an interactive user and prints out all of its factors in ascending order. For example, when the user enters 50, the program should print 2 5 5 because 2 * 5 * 5 = 50; when the user enters 60, the program should print 2 2 3 5 because 2 * 2 * 3 * 5 = 60 when the user enters 150, the program should print 2 3 5 5 because 2 * 3 * 5 * 5 = 150 User should be able to repeat procedure as many times as they like. In C++ program, write and test the module that processes the integer and print out all its factors in ascending order.arrow_forward
- Problem Description The hailstone sequence is defined as the integer sequence that results from manipulating a positive integer value n as follows: If n is even, divide it by 2 (using floor division) • If n is odd, multiply it by 3 and then add 1 Repeat this process until you reach 1. For example, starting with n = 5, we get the sequence 5, 16, 8, 4, 2, 1. If n is 6, we get the sequence 6, 3, 10, 5, 16, 8, 4, 2, 1. If n is 7, we get 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. If n is 8, we get the sequence 8, 4, 2, 1. As far as anyone can tell, this process will eventually reach 1 for any starting value, although mathematicians have been unable to formally prove this property as of yet. a. Write a Python function named hail () that takes a single integer argument. hail() should print out the sequence of numbers generated by applying the process above to the function parameter. This function does not return any value.arrow_forwardProgramming Problem 3 – Broken GPS Consider yourself driving with 60 miles/hour in a city that has only grid like streets, and your GPS is broken. The specifications of the problem are: • With (x, y) as the coordinates of the car, consider the initial position (0,0). • At each intersection, the only directions available are North, South, East or West • The GPS is broken, and it chooses the direction randomly at each intersection, which happens every 5 minutes • The assumption is that the car has the same speed at all times, including when it changes direction and turns. Write a program that calculates the direct distance from the initial point to the location point of the driver after one hour of driving (i.e. the distance between two points). Java Prograarrow_forwardPython Turtle Graphics Draw a spiral diagram using Python turtle package program follows 3 steps: Import the turtle module Create a turtle to control. Draw around using the turtle methods. You should consider the following points in your solution: The shapes should be drawn with the shown colors Yellow and white for the square-like shapes. Blue for the background. The prompt should have a turtle shape. The number of iterations should be 300 You should use only one loop. The number of the yellow color lines should be 200. The final shape of the output should be as shown in the picture attached. Make sure to set properly the starting position (x & y) of your drawing, to maintain the required diagram. video on youtube: https://www.youtube.com/watch?v=ZqoJD2RMu1Iarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning