#JAVA: Urgent ive been at this since yesterday Need help with an assignment due 9/3 which is today

27 messages · Page 1 of 1 (latest)

pseudo mauve
#

My professor has no resources on how to do this on his hub online i just need help doing this im new to coding
im using mac os
this is for java
yes this is for homework
im using cloudshell
my initials are EEP

DESCRIPTION: Write a program that outputs an empty rectangle made of asterisks that is 5 characters across and 4 characters down.

SPECIFICATIONS:

File name: Initials.java.
The starter code has been provided for this lab.
The code to print the initials should be in a separate method that is called by the main method.
The only acceptable characters to be displayed are letters or asterisks.
Students must use their own initials!
Each initial must consist of
exactly 7 lines of text consisting of
exactly 7 characters of either spaces or either the letter (corresponding to the initial) or asterisks.
Each line must consist of
exactly 3 initials,
exactly 23 characters: 7 characters per letter with one space separating the initials.
NOTE:

Highlight the 'Sample Output' by dragging over the characters with the left mouse button depressed. Observe that many lines end with 1 or more space-characters! Though a space-character may seem unnecessary, CodeGrade will be checking that each line consists of 23 characters: letters, asterisks, and space-characters!

thin sandal
#

What have you got so far? We're not gonna do the work for you

pseudo mauve
# thin sandal What have you got so far? We're not gonna do the work for you
  • @author Elijah Plaza

  • @since 9/2/2023
    */

    public class Initials {

    public static void main(String[] args) {
    drawInitials();
    }

    public static void drawInitials() {

    // ========== INSERT YOUR CODE HERE ==========
    // MY initials Elijah Emanuel Plaza EEP
    int width = 7; // width of one letter block
    int height = 7; // Height of one letter block
    int padding = 1; // Padding between initials and the rectangle
    String[] initials = {
    "EEP",
    "E ",
    "EE ",
    "E ",
    "EE ",
    "E ",
    "EE ",
    };

    // Calculate the total width of the rectangle
    int totalWidth = (width + padding) * 3;

    // Print the top border of the rectangle
    printHorizontalLine('*', totalWidth);

    for (int i= 0; i < height; i++){
    for (int j= 0; j < 3; j++){
    //print the left border of the rectangle
    System.out.print('*');

    // Print the intials with padding
    System.out.print(initials[i]);

    // Fill the remaining space with spaces
    if (j < 2){
    printSpaces(width - initials[i].length() + padding);
    }
    //Print the right border of the rectangle
    System.out.print('');
    }
    // Move to the next line
    System.out.println();
    }
    //Print the bottom border of the rectangle
    printHorizontalLine('
    ', totalWidth);
    }

    //Helper method to print a horizontal line of a given character
    public static void printHorizontalLine(char character, int length) {
    for (int i = 0; i < length; i++){
    System.out.print(character);
    }
    //Move to the next line
    System.out.println();
    }

    //Helper Method to print spaces
    public static void printSpaces(int count){
    for (int i= 0; i < count; i++){
    System.out.print(' ');
    }
    }
    }

pseudo mauve
regal crow
#

Can you explain why you put what you put in the initials array?

#

or just walk us through your code and explain what each line does?

pseudo mauve
regal crow
#

So this is a homework assignment and you didnt try anything yourself yet other than asking chatgpt?

#

I can help but you will need to put in some effort of your own, not expect other people (or chatgpt) to do it for you. That defeats the point of it being hw, the point is for you to learn by trying it yourself

#

So I think you should break this down into smaller problems, start by just thinking about how you would draw an E made out of * if you were doing it by hand. So first figure out how to draw an E, then after this we can move on to the P and putting it all together.
How wide should the E be?
How many * should go into each row? Try to work this out using pencil and paper if necessary

pseudo mauve
#

Hey champ. I agree with the rest: get your hands dirty. No shortcuts. Some ideas here: a printer uses 0 and 1 to know where to put a dot (small amount of ink in paper). Think that, for this assignment, a character could be a matrix of 0 and 1. Eg. E => {
{1,1,1,1,1,1,1},
{1,0,0,0,0,0,0},
{1,0,0,0,0,0,0},
{1,1,1,1,0,0,0},
{1,0,0,0,0,0,0},
{1,0,0,0,0,0,0},
{1,1,1,1,1,1,1}
}
So, you've to initialize a map of characters where the value is a matrix of 0 and 1 (suggestion: use java.util,Map), where the key is a java.lang.Character and the vale a byte[][] (an array of dimension 2 aka. a matrix).
Think about it, and come again with some ideas.

pseudo mauve
pseudo mauve
#

please walk me through it

regal crow
#

Read the last few messages that was sent here

#

We gave you ideas as a starting point to think about

pseudo mauve
#

like as in tutor me i just started this class

regal crow
#

I'm trying to walk you through it, but you ignored everything i said and just say "walk me through it" again

#

So idk what you want

#

What I said is, you should start by breaking this problem down into smaller problems. Start by solving the smaller problem of simply printing an E out of asterisks. To do this, think about what you need to print for each row of the E (how many asterisks and spaces on the first row, second row, etc)

#

I can help you but walking you through it doesn't mean do the homework for you. It means helping you get started, asking some useful questions for you to think about to help you do it step by step

regal crow
#

All he's said is "walk me through it" but when we actually try to give pointers and start walking him through it, he ignores it completely

pseudo mauve
#

im sorrry i just have no coding experience

#

im sorry im just a beginnner and i need help

regal crow