Here are the original instructions for the code below that I wrote. Write a method that accepts a maximum number as an argument and prints each number from 1 up to that maximum, inclusive, enclosed in square brackets. I want to make the program prompt a max # input from a user and pass that value to the printNumbers methods and then print the max from the user input. Is this possible? import java.util.Scanner; public class PrintNumbers { Scanner input = new Scanner(System.in); public static void printNumbers(int max) { for(int count = 1; count <= max; count++) { System.out.print("[" +count+ "]"); } } public static void main(String[] args) { printNumbers(10); } }

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter3: Using Methods, Classes, And Objects
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Here are the original instructions for the code below that I wrote.

Write a method that accepts a maximum number as an argument and prints each number from 1 up to that maximum, inclusive, enclosed in square brackets.

I want to make the program prompt a max # input from a user and pass that value to the printNumbers methods and then print the max from the user input.

Is this possible?

import java.util.Scanner;

public class PrintNumbers
{
Scanner input = new Scanner(System.in);

public static void printNumbers(int max)
{
for(int count = 1; count <= max; count++)
{
System.out.print("[" +count+ "]");
}
}
public static void main(String[] args)
{
printNumbers(10);
}
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Math class and its different methods
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT