#confused
48 messages · Page 1 of 1 (latest)
Hey, @wanton delta!
Please remember to /close this post once your question has been answered!
{
public static void main(String[] args)
{
String test1 = "WOW";
String test2 = "BEN";
String test3 = "SAMMY";
String test4 = "WILE";
String test5 = "APLUSCOMPSCI";
System.out.println(printTriangle(test1));
System.out.println(printTriangle(test2));
System.out.println(printTriangle(test3));
System.out.println(printTriangle(test4));
System.out.println(printTriangle(test5));
public static int printTriangle(String input) {
String tmp = input.substring(1);
StringBuilder builder = new StringBuilder(tmp);
builder = builder.reverse().append(input);
String line = builder.toString();
for(int i = 0; i < input.length(); i++){
for(int j = 0; j < line.length(); j++){
if(i + 1 == input.length() || Math.abs(j - line.length()/2) == i){
System.out.print(line.charAt(j));
}else{
System.out.print(" ");
}
}
System.out.println();
}
}
}```
You put the printTriangle method in the main method
giving same error
my bad i messed up
but now its giving me a error that says "cannot find symbol" pointing at the printtriangle in the main file
I think you put out of the class as well
Or you misspelled something
Lemme see the new code
Preferably a picture
So I don't have to keep track of curly braces
Oh
The print triangle is in another class
So do TriangleWord.printTriangle();
@wanton delta
yeah i think it works its jsut giving me a bug saying im missing a return statement even though its there
Its not
yeah i know its there and its still giving me the error
You didn't add a return value
That's why
System.out.println() and return are not the same
You have to add a return statement
In printTriangle
@wanton delta
what do i return
Idk
You should know
Otherwise change the int to void
If you don't want to return something
i would but it would give me the error "void typr not allowed here"