Question
Loops Objective: You will create a program that uses loops to print out a desired range of numbers. ((Someone by the name of @M zain
Loops
Objective: You will create a program that uses loops to print out a desired range of numbers.
((Someone by the name of @M zain just posted a ridiculous program that makes without the correct formatting and makes no sense! He literally responded within 30 secs after I made this post! Please do not respond to these questions if you are not going to write an actual program because it is costing me unnecessary money and time where I have to re-post this question again!))
Related SLOs:
SLO #1: Use an appropriate programming environment to design, code, compile, run, and debug computer programs.
SLO #3: Illustrate basic programming concepts such as program flow and syntax of a high-level general-purpose language and basic security practices.
SLO #4: Demonstrate working with primitive data types, strings, and arrays.
Instructions:
Using jGRASP, write a Java program named LastnameFirstname06.java, using your last name and your first name, that does the following:
Uses a while loop to print the numbers from 3 - 19.
Uses a do-while loop to print the numbers from 42 - 56.
Uses a for loop to print the numbers from 87 - 95.
Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive, beginning with the first number that the user inputted and ending with the second number the user inputted.
Note: Consider that your user's second number can be lower! (see example below)
Note: Also consider that your user might give you two of the same number.
Ask the user for a phrase to print. Ask the user how many times they want the program to print the phrase. Use a loop to print their phrase for the specified amount of times.
Your program MUST:
Use a while, do-while, and for loop as noted in the instructions. The fourth and fifth loops are your choice.
Actively use in-line comments stating what each section of code does.
Use try/catch, BUT only if necessary.
Your program must conform to the Java coding standards reviewed in class.
Your program should not use code/concepts we have not yet covered. You must demonstrate that you have mastered the concepts covered in class.
Remember to always begin your code with the following documentation comments:
/**
* Short description of the program. (Make sure to insert short description of the program and what it does there)
*
* @author Doe, John
* @assignment ICS XXX Assignment XX
* @date Today's Date
* @bugs Short description of bugs in the program, if any.
*/
Expected Output:
This is an example of what your program should output:
----jGRASP exec: java DoeJohn06
I'm going to print out the numbers 3-19 using a while loop:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
I'm going to print out the numbers 42-56 using a do-while loop:
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
I'm going to print out the numbers 87-95 using a for loop:
87 88 89 90 91 92 93 94 95
Now I'll print whatever numbers you'd like!
Give me a starting number:
2
Give me an ending number:
-4
I see that your ending number is lower. Okay, I'll count down!
2 1 0 -1 -2 -3 -4
Finally, I'll print any phrase you want, for any amount of times you want!
What phrase should I print?
noot noot
How many times should I print it?
5
Got it, I'm going to print "noot noot" 5 times! Here we gooooo...
noot noot
noot noot
noot noot
noot noot
noot noot
Hope you enjoyed my program built on loops. Bye! :)
----jGRASP: operation complete.
Criteria:
-Program must compile and/or output is correct.
-Program properly anticipate and handle exceptions (if necessary).
-Program output is descriptive and explain the program in clear terms to the user.
-Program comply with Java coding standards, including properly commenting your code.
-Program submitted to specifications. For example, documentation comments are included and complete, file name follows the
specified format, your name included in the file name, file attached, etc.
-Program has no miscellaneous mistakes, bugs, or problems.
Step by Step Solution
3.45 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
Java This program demonstrates the use of while dowhile and for loops along with user input and co...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