Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write in Java Source Code. Thank You Lab6A (Warmup: You may have played a game called Stop Repeating Yourself when you were a kid. The
write in Java Source Code. Thank You
Lab6A (Warmup: You may have played a game called "Stop Repeating Yourself when you were a kid. The premise of the game is you repeat the phrase "Stop Repeating Yourself over and over again to annoy the other person. We will write a program similar to this game. For this lab, you will prompt the user for input. If the user enters anything other than cookie, the program will respond with "Gimme a cookie". To make the program stop running, the user needs to enter "cookie". You need to write this program using a do-while loop. You will receive no credit if you use a "for" or "While" loop to solve this problem. Hint: Remember how to compare strings! The sample run is shown below. User input is in bold. Sample output: Gimme a cookie: who is this? Gimme a cookie: I'm not joking Gimme a cookie: What is going on? Gimme a cookie: help Gimme a cookie: cookie Lab6B: Min/Max We are going to practice working with a while loop. For this program, prompt the user to enter an integer between negative 1000 (-1000) and positive 1000 (+1000). After each number is entered the program will print out the maximum and minimum number based on the numbers that have been entered so far. If the user enters the program will print out the maximum and minimum numbers and then stop running. To prevent an out of bounds error, you need to initialize your minimum to be -1001 and your maximum to be +1001. Remember, your numbers must be integer values. Here's a challenge for advanced students: If you want to code this to work regardless of the range, how would you do it? You could use Math MIN and Math Max, but is there another way? The sample run is shown below. User input is in bold. Sample output: Enter a number between -1000 and +1000: 6 Min is 6 Max is 6 Enter a number between -1000 and +1000: 11 Min is 6 Max is 12 Enter a number between -1000 and +1000: -3 Min is - 3 Max is 11 Enter a number between -1000 and +1000: 99 Min is -3 Max is 99 Enter a number between -1000 and +1000: -45 Min is -45 Max is 99 Enter a number between -1000 and +1000: 3 Min is -45 Max is 99 Enter a number between -1000 and +1000: 0 Min is -45 Max is 99 Lab6C: Well, that's an odd question! The final loop we are going to practice using for this lab is a for loop. Write a program that prompts the user to enter two positive numbers. The program will add all of the odd numbers in between the two inputted values and return the sum. The program must work even if the starting number is larger than the ending number. Hint: Compare a loop that counts up to a loop that counts "down." What's the difference? Start by getting sample output #1 and #2 working, then work on #3. A sample run is shown below. User input is in bold. Sample output 11: Enter a starting number: 3 Enter an ending number: 7 Sum of odds is: 15 Sample output 12: Enter a starting number: 10 Enter an ending number: 20 Sum of odds is: 75 Sample output #3: Enter a starting number: 20 Enter an ending number: 10 Sum of odds is: 75 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started