Showing posts with label Rectangle. Show all posts
Showing posts with label Rectangle. Show all posts

Wednesday, June 29, 2022

Rectangle

 Rectangle

Problem Statement
Give integer values M and N. Using the character ‘*’ draw a rectangle of height M and breadth N

import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

class Main {
    
    public static void main(String[] args) 
    {
        int rows, columns, i, j;
        Scanner sc = new Scanner(System.in);
    
        rows = sc.nextInt();    

        columns = sc.nextInt();     
            
        for(i = 1; i <= rows; i++)
        {
            for(j = 1; j <= columns; j++)
            {
                //System.out.print("* "); 
                if (i == 1 || i == rows || 

                    j == 1 || j == columns)            

                    System.out.print("*");            

                else

                    System.out.print(" ");
            }
            System.out.println(); 
        }
    }
}

ads vert

Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody

  Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody < table >      < thead >    ...