do this to follwing code : 1) Provide comments in your code.  2)Provide a program design. 3) Browse the API Documentation to see all the features of the following classes: Point, Rectangle, String. code :  import java.util.*; public class Main {       public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int rectangle_count=0;         Random random = new Random();         try{             System.out.print("Please enter the width and the height of the given rectangle: ");             int width = sc.nextInt();             int height = sc.nextInt();             System.out.print("Please enter how many rectangles you would like to generate: ");             rectangle_count = sc.nextInt();             while(rectangle_count <=0){                 System.out.println("Error: Enter integer value > 0...Try Again");                 System.out.print("lease enter how many rectangles you would like to generate: ");                 rectangle_count = sc.nextInt();             }             System.out.println("**********************************************************************");             System.out.println("*\tRect#\t*\tR\t(\tx, \ty, \tw, \th\t)\t*\tcontained corners\t*");             System.out.println("**********************************************************************");             for(int i=0;i

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

do this to follwing code :

1) Provide comments in your code.

 2)Provide a program design.

3) Browse the API Documentation to see all the features of the following classes: Point, Rectangle, String.

code : 

import java.util.*;

public class Main {

 

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int rectangle_count=0;
        Random random = new Random();

        try{
            System.out.print("Please enter the width and the height of the given rectangle: ");
            int width = sc.nextInt();
            int height = sc.nextInt();
            System.out.print("Please enter how many rectangles you would like to generate: ");
            rectangle_count = sc.nextInt();
            while(rectangle_count <=0){
                System.out.println("Error: Enter integer value > 0...Try Again");
                System.out.print("lease enter how many rectangles you would like to generate: ");
                rectangle_count = sc.nextInt();

            }
            System.out.println("**********************************************************************");
            System.out.println("*\tRect#\t*\tR\t(\tx, \ty, \tw, \th\t)\t*\tcontained corners\t*");
            System.out.println("**********************************************************************");
            for(int i=0;i<rectangle_count;i++){
                int w= (int)Math.floor(random.nextDouble()*width);
                int h=(int)Math.floor(random.nextDouble()*height);
                int x = (int)Math.floor(random.nextDouble()*(width-w));
                int y = (int)Math.floor(random.nextDouble()*(height-h));
                System.out.printf("*\t%d\t*\tR\t(\t%d, \t%d, \t%d, \t%d\t)\t*\t0\t*\n",(i+1),x,y,w,h);


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


        }catch(Exception e){
            System.out.print("Error: It is not Integer value...Exit.");
        }


    }

}

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY