Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Take the SI and PASS Mid-semester Survey!
- Take this survey at your leisure, but not during the session.
- This will help us leaders by providing anonymous feedback on the program!
- https://unf.co1.qualtrics.com/jfe/form/SV_3xy2D1S0x8nsR26
- As well, here are the transcribed questions and answers to today's Kahoot:
- https://pastebin.com/F00C8Mf0
- PROBLEM #1: Simple Countdown
- Compose a program using a WHILE loop that prints a countdown from 10 to 0.
- SAMPLE OUTPUT:
- 10 9 8 7 6 5 4 3 2 1
- PROBLEM #2: Looping based on User Input
- Write a program using a WHILE loop that will print a number counting up based
- on a user input.
- Starting at 0, print each number counting up UNTIL IT REACHES the user's inputted number.
- After every 10 iterations of the loop, print a newline character (Use an if statement to accomplish this, you may need modulo).
- SAMPLE OUTPUT (User enters 10):
- Enter in the number of loops: 10
- 0 1 2 3 4 5 6 7 8 9
- MORE SAMPLE OUTPUT (User enters 100):
- Enter in the number of loops: 100
- 0 1 2 3 4 5 6 7 8 9
- 10 11 12 13 14 15 16 17 18 19
- 20 21 22 23 24 25 26 27 28 29
- 30 31 32 33 34 35 36 37 38 39
- 40 41 42 43 44 45 46 47 48 49
- 50 51 52 53 54 55 56 57 58 59
- 60 61 62 63 64 65 66 67 68 69
- 70 71 72 73 74 75 76 77 78 79
- 80 81 82 83 84 85 86 87 88 89
- 90 91 92 93 94 95 96 97 98 99
- PROBLEM #3: Looping Based on User Input 2
- Take your solution from problem #2, and edit it to print in descending order instead.
- USE A FOR LOOP INSTEAD.
- As well, limit the input the user can enter to be between 1 and 100 (You may need to use break for this).
- SAMPLE OUTPUT:
- Enter an integer between 1 and 100: 80
- 80 79 78 77 76 75 74 73 72 71
- 70 69 68 67 66 65 64 63 62 61
- 60 59 58 57 56 55 54 53 52 51
- 50 49 48 47 46 45 44 43 42 41
- 40 39 38 37 36 35 34 33 32 31
- 30 29 28 27 26 25 24 23 22 21
- 20 19 18 17 16 15 14 13 12 11
- 10 9 8 7 6 5 4 3 2 1
- PROBLEM #4: Print a number backwards one digit at a time
- Write a program that gets an integer from a user and prints out the number backwards.
- Using modulo and division, print the RIGHT-MOST DIGIT of that number iteratively using a loop.
- You may use a for or while loop.
- Recall that using division can reduce a number by a power of 10 (For example, 1234 divided by 10 would give you 123)
- and modulo can be used to get the digit in the tens place.
- SAMPLE OUTPUT
- Enter a number and I will print it backward: 1234
- 4321
- PROBLEM #5: Factorial
- https://www.mathsisfun.com/numbers/factorial.html
- Write a program that will determine the factorial of a user supplied number using a
- for loop.
- SAMPLE OUTPUT:
- Enter in a number for factorial: 5
- Factorial of 5! = 120
- PROBLEM #6: Do-While Loops
- Write a program using a DO-WHILE loop that takes integer input from the user.
- The user should be prompted to enter positive integer values. If the user enters 0, it will quit.
- Data is entered one integer at a time. Zero is used to signify the end of a user’s input.
- After the user enters 0, the program will print the minimum, maximum and average integer of ALL the user’s input.
- Also, the zero is not a member of the list, don’t use it to determine the average.
- Test your program with the following data:
- 24, 7, 31, 64, 57, 7, 63, 31, 15, 7, 2, 4, and 6.
- Your min should be 2, max should be 64 and average should be 24.46 with this test
- data.
- SAMPLE OUTPUT:
- Enter a positive integer or 0 to stop and provide statistics: 6
- Enter a positive integer or 0 to stop and provide statistics: 7
- Enter a positive integer or 0 to stop and provide statistics: 8
- Enter a positive integer or 0 to stop and provide statistics: 9
- Enter a positive integer or 0 to stop and provide statistics: 10
- Enter a positive integer or 0 to stop and provide statistics: 0
- Min: 6 Max: 10 Avg: 8.00
Add Comment
Please, Sign In to add comment