About 15,100,000 results
Open links in new tab
  1. How to Print a square with asterisks in java with while loop only?

    Nov 29, 2013 · I would like to know how to print a square with asterisks in java with a while loop only but with out for loop and with out any logic operations like: AND or OR. This code should do something like that: if we enter 4 it should print: but it does some thing else, like that: Scanner input = new Scanner(System.in); int squareside ;

  2. java - Printing a Square with loops - Stack Overflow

    Nov 27, 2013 · public static void main(String[] args) { Scanner input = new Scanner(System. in ); System.out.print("Please enter the height of the box: "); int x = input.nextInt(); System.out.println("Please enter a width for the box: "); int y = input.nextInt(); drawbox(x, y); static void drawbox(int x, int y) { for (int j = 0; j < y; j++) {

  3. Java - Printing an empty square using nested loops

    class square1 { public static void main(String[] args) { String star = "*"; String space = " "; int MAX = 5; for (int row = 0; row < MAX; row++) { for (int col = 0; col < MAX; col++) { if (row == 0 || row == MAX - 1) { System.out.print(star); } else if (col == 0 || col == MAX - 1) { System.out.print(star); } else { System.out.print(space ...

  4. Java Program to Print Square Number Pattern - Tutorial Gateway

    Write a Java Program to Print Square Number Pattern using For Loop, and While Loop with example. This Java program allows entering any side of a square (all sides are equal). Next, this program displays a square number pattern of 1’s until it reaches to the user-specified rows and columns. private static Scanner sc;

  5. Java Program to Print a Square Pattern for given integer

    Aug 5, 2022 · Here, we will implement a Java program to print the square star pattern. We will print the square star pattern with diagonals and without diagonals. Example: ********************** * * * * * * * * * * * * ********************** Approach: Step 1: Input number of rows and columns.

  6. Java program to print a square using any character

    This tutorial is on how to print a square like below using any character in Java : We will create the program to print the square by using any character like ’*’,’%’,’$’ etc. Not only by ’&‘.

  7. How to Print Square Pattern in Java - CodeSpeedy

    In this program, we will learn how to display the pattern of the square using Java. We will use some while loops and for loops for the iteration. Import the util class; Use the Scanner method for input; How to take input from the user

  8. Java Program to Print Square with Row wise Increasing Number Pattern

    Nov 30, 2024 · In this program we are going to see how to print the square with row wise increasing number pattern. Java Code to Print Square with Row wise Increasing Number Pattern; C Code to Print Square with Row wise Increasing Number Pattern; C++ Code to Print Square with Row wise Increasing Number Pattern

  9. java - printing an empty square using loops - Stack Overflow

    Nov 9, 2014 · I need to print an empty square and my code prints this instead, and I have no idea why. Can you explain why it's a rectangle and not a square and how can I fix it? This is my code:

  10. Java Program to Print Square With Diagonal Numbers Pattern

    Write a Java program to print the square with all zeros except the diagonal numbers pattern using for loop.

  11. Some results have been removed
Refresh