sizing problem

im looking to size up my output based of user input but when user input size is greater then 4 then the spacing is all off
4 Replies
JavaBot
JavaBot2w ago
This post has been reserved for your question.
Hey @adopted apple! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
adopted apple
adopted appleOP2w ago
import java.util.Scanner;
public class AssignedAsciiArt {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("What size space needle would you like to see? ");
int size = in.nextInt();
point(size);
body(size);




}
public static void point(int size){
for(int i = 1;i<=size;i++){
for(int u=1;u<=size+8;u++){
System.out.print(" ");
}
System.out.println("||");
}
for(int n = 1;n <= size;n++){
int spaceloop =(n*-3)+12;
for (int space = 1; space <= spaceloop; space++) {
System.out.print(" ");
}


System.out.print("__/");
if(n==1){
System.out.print("||");
}
for(int y = 1; y<=2;y++){
if(n>1){
if(y==2){
System.out.print("||");
}
for(int t = 1;t<=n-1;t++){

System.out.print(":::");
}
}
}
System.out.print("\\__\n");
}
}


public static void body(int size){
for(int i = 1;i<=size;i++){
for(int u=1;u<=size+8;u++){
System.out.print(" ");
}
System.out.println("||");
}

for(int p = 1;p<=size*size;p++){
for(int j=1;j<=2;j++){

if(j==1){


System.out.print(" |");
}
if(j==2){
System.out.print("||");
}
for(int q = 1;q<=size-2;q++){
System.out.print("%");
}
if(j==2){
System.out.println("|");
}




}
}
}
}
import java.util.Scanner;
public class AssignedAsciiArt {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("What size space needle would you like to see? ");
int size = in.nextInt();
point(size);
body(size);




}
public static void point(int size){
for(int i = 1;i<=size;i++){
for(int u=1;u<=size+8;u++){
System.out.print(" ");
}
System.out.println("||");
}
for(int n = 1;n <= size;n++){
int spaceloop =(n*-3)+12;
for (int space = 1; space <= spaceloop; space++) {
System.out.print(" ");
}


System.out.print("__/");
if(n==1){
System.out.print("||");
}
for(int y = 1; y<=2;y++){
if(n>1){
if(y==2){
System.out.print("||");
}
for(int t = 1;t<=n-1;t++){

System.out.print(":::");
}
}
}
System.out.print("\\__\n");
}
}


public static void body(int size){
for(int i = 1;i<=size;i++){
for(int u=1;u<=size+8;u++){
System.out.print(" ");
}
System.out.println("||");
}

for(int p = 1;p<=size*size;p++){
for(int j=1;j<=2;j++){

if(j==1){


System.out.print(" |");
}
if(j==2){
System.out.print("||");
}
for(int q = 1;q<=size-2;q++){
System.out.print("%");
}
if(j==2){
System.out.println("|");
}




}
}
}
}
heres the code^
dan1st
dan1st2w ago
you set spaceloop to be (n*-3)+12 so if n>4, the result is <0 and idk what you are trying to draw that way but the hardcoded value 8 may also be an issue maybe 12 us supposed to be size*3 and 8 is supposed to be size*2? also you have a hardcoded amount if spaces in your last loop - how many spaces are that and why?
JavaBot
JavaBot2w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?