C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Write a function print_shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N : Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.".
Sample output with input: 2
1 : Lather and rinse.
2 : Lather and rinse.
Done.
Hint: Define and use a loop variable.
''' Your solution goes here '''
user_cycles = int(input())
print_shampoo_instructions(user_cycles)
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images
Knowledge Booster
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
- (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.arrow_forwardWrite a function print_shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N : Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.".Sample output with input: 1: Lather and rinse. 2: Lather and rinse. Done. So far, this is what I have and it works except that it doesnt do 2 lather and rinse outputs: def print_shampoo_instructions(num_cycles): if num_cycles < 1: print('Too few') elif num_cycles > 4: print('Too many') else: print(str(num_cycles - 1) + ': Lather and rinse.') num_cycles += 1 user_cycles = int(input())print_shampoo_instructions(user_cycles) user_cycles = int(input())print_shampoo_instructions(user_cycles)arrow_forwardWrite a function print_shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N : Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.".Sample output with input: 2 1: Lather and rinse. 2: Lather and rinse. Done. Hint: Define and use a loop variable. I am getting the correct output,but i can't get rid of the white space between the number and the ':' 1 : Lather and rinse. 2 : Lather and rinse. Done.arrow_forward
- Write a function print_shampoo_instructions with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N: Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.". Sample output with input: 2 1: Lather and rinse. 2: Lather and rinse. Done. Hint: Define and use a loop variable. Learn how our autograder works 461710.3116374.qx3zqy7 1 234 3 | Your solution goes here ITT 5 user_cycles = int(input()) 6 print_shampoo_instructions(user_cycles) 1 pas All t pasarrow_forwardpython Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N : Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.".Sample output with input: 21 : Lather and rinse. 2 : Lather and rinse. Done. i keep getting this errorarrow_forwardWrite a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than 4, print "Too many.". Else, print "N : Lather and rinse." num_cycles times, where N is the cycle number, followed by "Done.".Sample output with input: 2 1 : Lather and rinse. 2 : Lather and rinse. Done. Hint: Define and use a loop variable.arrow_forward
- Define function print popcorn_time() with parameter bag ounces. If bag ounces is less than 3, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6* bag ounces followed by 'seconds". End with a newline. Sample output with input: 7 42 seconds 1 2 Your solution goes here *** 3 4 user_ounces int(input()) 5 print popcorn_time(user_ounces) Iarrow_forwardDefine function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bag_ounces followed by "seconds". End with a newline. Remember that print() automatically adds a newline. Python Languagearrow_forwardMy Birthday Function Write a well-documented Python program, hmwk4Q4.py, that simulates a single trial of a person walking into a room on N people and determining if their birthday matches any of the other N people in the room. Design a function myBirthday (N) that returns True if a match is found, or False if no match is found. Import the python random number module into your program. On a single trial, with a user input 200 people, you may not find someone with your birthday. If you manually rerun the simulation ten times, your code, however, should see that approximately four (4.22 exactly) times there is a match to your birthday.arrow_forward
- Write a function sumOddInts(). sumOddInts should return the sum of all odd integers between the values provided to the two parameters, inclusive, e.g., sumOddInts(5,9) should return 21. start and finish do not have to be odd, e.g, sumOddInts (4,8) should return 12. start and finish do not have to be positive, e.g., sumoddlnts(-5,7) should return 7, However, finish may be assumed to be greater or equal to start. whereas Python has a modulo operator "%", MATLAB has a built-in mod() function that returns the remainder. For instance, >> mod (13,5) ans = 3 >> mod (13,2) ans = 1 Notes: End all assignment statements with a semi-colon to suppress output to screen. Include the key word end at the end of your function.arrow_forwardNEED HELP WITH THIS import random print(random.randint(1,6)) #prints a number between 1 and 6. #or: x = random.randint(1,6) print(x) #prints a number between 1 and 6. write a python program that simulates a game with two dice roll based on their sum and value. Your program should: Define a function try_your_luck(dice1, dice2) that takes two arguments i.e., the numbers generated by randint() function (use randint twice). The random numbers should be passed to the function as argument The player wins some money, when: a. Sum of both dice is divisible by three, player wins $5 b. Same number on both die, player wins $10 c. For all other cases, print "try again" Player loses the game, when: a. Sum is greater than 10 and odd b. Sum is 7. Display an appropriate message for each case (player wins or loses).arrow_forwardWrite a function that receives a positive integer n as a parameter, then it must calculate the sum 1+2+3+...+n. Finally return the result of the sum and in the main function print that result to the screen. The output of the program should be just the value of the sum. Look at the example. Input: A positive integer n Output: The result of the addition 1+2+3...+n Program execution example: Entry 6 Departure twenty-one Entry 5Output fifteen Entry 7 Departure 28arrow_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 PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning