Computer Science Canada

contiuning on the same line (looping)

Author:  google29 [ Tue Oct 06, 2009 6:08 pm ]
Post subject:  contiuning on the same line (looping)

i am always having trouble with this. I still cannot output some code that can output something on the same line.

eg.

-----xxxx-----------xxxx
------xxxx---------xxxx
-------xxxx-------xxxx
--------xxxx-----xxxx

well something like that
like in between the spaces
how do u loop this sort?

Author:  andrew. [ Tue Oct 06, 2009 7:47 pm ]
Post subject:  RE:contiuning on the same line (looping)

Here's a hint:
Use "System.out.print" to print everything to one line. If you print "\n" from System.out.print, you will get a new line.

Author:  google29 [ Tue Oct 13, 2009 9:35 pm ]
Post subject:  Re: contiuning on the same line (looping)

it is with this program
i am trying to make a giant x with any inputted character

EDIT
can anyone help me make this work

Author:  S_Grimm [ Thu Oct 15, 2009 3:55 pm ]
Post subject:  Re: contiuning on the same line (looping)

I will not make it work, but here is an idea to help you. (BTW: don't even try to submit this as your own, because if you knew how to use InputStreamReader, BufferedInputStream, System.in and System.out, you would be using them instead of console. Also your teacher would be very suspicious of where you learned this)
Java:

import java.io.*;

public class Design
{
    static InputStreamReader isr = new InputStreamReader (System.in);
        static BufferedReader br = new BufferedReader (input);
   
    public static void main (String [] args)
    {
        System.out.print ("Input a letter : ");
        string a;
        a = br.readLine();
       
        for (int i = 0; i < 10 i++)
        {
            System.out.print (a);
           
            for (int z = 0; z <= i; z++)
            {
                System.out.print (" ");
            }
            System.out.print("\n");
        }
    }
}


to make the "X" shape, look into a decreasing loop followed by an increasing loop


: