Results 1 to 2 of 2
  1. #1
    SgtGump is offline Member
    Join Date
    Nov 2013
    Rep Power

    Default Looking for HELP with this code!

    I have an assignment and im not sure how to go about doing it,
    any help would be much appreciated.

    Ive attached a screen capture of an example of the assignment .

    I know for sure i will need 3 arrays like so:
    char firstLine[] = {'\u2501', '\u250F', '\u2533', '\u2513'};
    char internalLine[] = {'\u2501', '\u2523', '\u254B', '\u252B'};
    char lastLine[] = {'\u2501', '\u2517', '\u253B', '\u251B'};

    i have this code from my previous assignment which helps towards this assignment,
    just needs to be altered and split into methods.

    public static void main(String[] args) {
    int column,width;

    //unicode for the first,middle and last lines.
    char firstLine[] = {'\u250c', '\u2500','\u252c', '\u2510'};
    char middleLine[]={'\u2502'};
    char lastLine[] = {'\u2514','\u2500', '\u2534', '\u2518'};

    Scanner input= new Scanner (;

    //asking for user input of the number of boxes and the width.
    System.out.println("Enter the number of columns:");
    System.out.println("Enter the box width:");

    //the first line

    for (int first=1;first<=column;first++){ //if counter is less then or equal to the number of columns it will loop
    for (int i=1;i<=width;i++){
    System.out.print(firstLine[1]); //if counter is less then or equal to the width it will print unicode \u2500
    if (first<column){ //if the counter is less then column num print unicode \u252c
    System.out.print(firstLine[3]+"\n"); //else print unicode \u2510

    //the middle line
    for (int mid=1;mid<=column;mid++){
    System.out.print(middleLine[0]); // if counter less then or equal to column print out unicode \u2502
    for (int x=1;x<=width;x++){
    System.out.print(" "); //if counter is less then or equal to width print out a space

    //the last line
    System.out.print(lastLine[0]+""); // print unicode \u2514

    for (int last=1;last<=column;last++){
    for(int y=1;y<=width;y++){
    System.out.print(lastLine[1]); //print unicode \u2500
    if (last<column){
    System.out.print(lastLine[2]); //print unicode \u2534
    System.out.print(lastLine[3]+"\n"); //print unicode \u2518
    Attached Thumbnails Attached Thumbnails Looking for HELP with this code!-1234.png  

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Looking for HELP with this code!

    Quote Originally Posted by SgtGump View Post
    just needs to be altered and split into methods.
    You better get started then. Come back when you have a specific question.

Similar Threads

  1. Replies: 1
    Last Post: 03-25-2012, 03:40 AM
  2. Replies: 16
    Last Post: 01-31-2012, 08:36 PM
  3. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  4. Replies: 0
    Last Post: 02-21-2011, 11:50 AM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts