@M zain do not respond to this question again!!! You need to stop posting ridiculous solutions to my question. You literally respond in seconds after
@M zain do not respond to this question again!!! You need to stop posting ridiculous solutions to my question. You literally respond in seconds after this question that I post with crazy weird questions. This is the second time that you did this. You have just been reported!
Here is an update of the most recent solution by @Jai Avinash below but I'm having 2 errors. It was 3 errors at first but I corrected a few things but it's still showing as 2 errors now so I still can't compile or run it. Here is the error codes:
----jGRASP exec: javac -g DoeJohn06.java
WilliamsStanley06.java:78: error: reached end of file while parsing
}
^
DoeJohn06.java:55: error: reached end of file while parsing
else {
^
2 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Please help me make the corrections to get it to work properly. Here is the recent code below:
import java.util.Scanner;
import java.util.Random;
/**
* This program demonstrates the use of different types of loops to print numbers and phrases as specified by the user.
*
* @author Doe, John
* @assignment ICS XXX Assignment 06
* @date February 24, 2024
* @bugs 0 errors 2
*/
public class DoeJohn06 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Using a while loop to print numbers from 3 to 19
System.out.println("I'm going to print out the numbers 3-19 using a while loop:");
int i = 3;
while (i <= 19) {
System.out.print(i + " ");
i++;
System.out.println();
// Using a do-while loop to print numbers from 42 to 56
System.out.println("I'm going to print out the numbers 42-56 using a do-while loop:");
i = 42;
do {
System.out.print(i + " ");
i++;
while (i <= 56);
System.out.println();
// Using a for loop to print numbers from 87 to 95
System.out.println("I'm going to print out the numbers 87-95 using a for loop:");
for (i = 87; i <= 95; i++) {
System.out.print(i + " ");
System.out.println();
// Asking the user for two numbers and printing numbers between them
System.out.println("Now I'll print whatever numbers you'd like!");
System.out.println("Give me a starting number:");
int start = scanner.nextInt();
System.out.println("Give me an ending number:");
int end = scanner.nextInt();
if (start <= end) {
System.out.println("Okay, I'll count up!");
for (i = start; i <= end; i++) {
System.out.print(i + " ");
else {
System.out.println("I see that your ending number is lower. Okay, I'll count down!");
for (i = start; i >= end; i--) {
System.out.print(i + " ");
System.out.println();
// Asking the user for a phrase and printing it multiple times
System.out.println("Finally, I'll print any phrase you want, for any amount of times you want!");
System.out.println("What phrase should I print?");
scanner.nextLine(); // Consume the newline character
String phrase = scanner.nextLine();
System.out.println("How many times should I print it?");
int times = scanner.nextInt();
System.out.println("Got it, I'm going to print "" + phrase + "" " + times + " times! Here we gooooo...");
for (i = 0; i < times; i++) {
System.out.println(" " + phrase);
System.out.println("Hope you enjoyed my program built on loops. Bye! :)");
}
}
------------------------------------
Here is the original question below:
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
There are 3 Steps involved in it
Step: 1
Since you requested the same instructions and specification...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