The first screenshot is my code and when I run the program. It ouputs to: bop bop bop but I need it to output all on one line like the 2nd screenshot. " bop bop bop" and I need to know how to end it with a period after the user plugs in how many times they want it to repeat for. Can't use the 'end=""' function or anything complex. again no using "end=" function or any other similar function. Must stick to using while looping function. Cannot use "import sys" or "sys.stdout.write". must use simple while loop command repeating bop 3 times should print “bop bop bop”.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

The first screenshot is my code and when I run the program. It ouputs to:

bop

bop

bop

but I need it to output all on one line like the 2nd screenshot. " bop bop bop" and I need to know how to end it with a period after the user plugs in how many times they want it to repeat for. Can't use the 'end=""' function or anything complex.

again no using "end=" function or any other similar function. Must stick to using while looping function.

Cannot use "import sys" or "sys.stdout.write". must use simple while loop command

repeating bop 3 times should print “bop bop bop”.

What beat do you want to repeat? bop
How many times do you want to repeat it? 3
bop bop bop
Transcribed Image Text:What beat do you want to repeat? bop How many times do you want to repeat it? 3 bop bop bop
counter: int = 0
maximum: str = str(input("What beat do you want to repeat? "))
8
number_of_times: int = int(input("How many times do you want to repeat it? "))
9
10
while counter < number_of_times:
11
counter = counter + 1
12
print(maximum)
13
14
if number_of_times <= 0:
15
print("No beat...")
16
+56N
Transcribed Image Text:counter: int = 0 maximum: str = str(input("What beat do you want to repeat? ")) 8 number_of_times: int = int(input("How many times do you want to repeat it? ")) 9 10 while counter < number_of_times: 11 counter = counter + 1 12 print(maximum) 13 14 if number_of_times <= 0: 15 print("No beat...") 16 +56N
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT