Advertisement
JackHoughton00

DisplayBox

Apr 10th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. package actualdisplaybox;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ActualDisplayBox {
  6. public static void drawBar(int w) {
  7. for (int j=0;j<w;j++)
  8. System.out.print("X");
  9. System.out.println("");
  10.  
  11. }
  12. public static void drawBar(int w,String character) {
  13. for (int j=0;j<w;j++)
  14. System.out.print(character);
  15. System.out.println("");
  16. }
  17. public static void drawBox (int width, int height) {
  18. for (int i=0;i<height;i++)
  19. drawBar(width);
  20.  
  21. }
  22. public static void drawBox(int width,int height,String myChar){
  23. for (int i=0;i<height;i++)
  24. drawBar(width,myChar);
  25. }
  26.  
  27. public static void main(String[] args) {
  28. Scanner input = new Scanner(System.in);
  29. int length,width;
  30. String response, character;
  31. System.out.print("Enter the box width:");
  32. width = input.nextInt();
  33. System.out.print("Enter the box length:");
  34. length = input.nextInt();
  35. System.out.print("Do you want to use a different character?(y or n):");
  36. response = input.next();
  37. if (length>0 && width>0) {
  38. if (response.equals("y")){
  39. System.out.print("Enter the single character you want to display:");
  40. character = input.next();
  41. drawBox(length,width,character);
  42. }
  43. else
  44. drawBox(length,width);
  45. }
  46. else
  47. System.out.println("Sorry, your box is too small to draw.");
  48. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement