Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package actualdisplaybox;
- import java.util.Scanner;
- public class ActualDisplayBox {
- public static void drawBar(int w) {
- for (int j=0;j<w;j++)
- System.out.print("X");
- System.out.println("");
- }
- public static void drawBar(int w,String character) {
- for (int j=0;j<w;j++)
- System.out.print(character);
- System.out.println("");
- }
- public static void drawBox (int width, int height) {
- for (int i=0;i<height;i++)
- drawBar(width);
- }
- public static void drawBox(int width,int height,String myChar){
- for (int i=0;i<height;i++)
- drawBar(width,myChar);
- }
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int length,width;
- String response, character;
- System.out.print("Enter the box width:");
- width = input.nextInt();
- System.out.print("Enter the box length:");
- length = input.nextInt();
- System.out.print("Do you want to use a different character?(y or n):");
- response = input.next();
- if (length>0 && width>0) {
- if (response.equals("y")){
- System.out.print("Enter the single character you want to display:");
- character = input.next();
- drawBox(length,width,character);
- }
- else
- drawBox(length,width);
- }
- else
- System.out.println("Sorry, your box is too small to draw.");
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement