Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In java please, The first program should print out a box, and the 2nd one should

ID: 3738635 • Letter: I

Question

In java please,

The first program should print out a box, and the 2nd one should print out the outline of the box. Thanks so much, I'm really lost

Write a program called Box that prints a filled box of asterisks based on dimensions entered by the user. The program should ask the user for the length and width of a box and then print out a solid box of those dimensions. You should use nested for loops for this exercise. Example: Input the width of the box: 4 Input the height of the box: 5 Problem 5 Write a program called BoxOutline that prints the outline of a box using asterisks based on dimensions entered by the user. The program should ask the user for the length and width of a box and then print out a solid box of those dimensions. You should use nested for loops for this exercise Example Input the width of the box: 4 Input the height of the box: 5 ??.

Explanation / Answer

Program 4) Answer)

import java.util.Scanner;

public class Pattern {

public static void main(String args[]) {

Scanner s = new Scanner(System.in); // Using Scanner class to take input from the user

System.out.println("Input the width of the box");

int width= s.nextInt(); // Storing the width from the user input

System.out.println("Input the height of the box");

int height = s.nextInt(); // Storing the height from the user input

for (int i=0; i<height; i++){

for (int j=0; j<width; j++){

System.out.print("*"); // Printing * symbol

}

System.out.println(); // Printing the new line after each row is done printing the *

}

  

}

}

Output:

Input the width of the box 4

Input the height of the box 5

****

****

****

****

****

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote