2 Replies - 916 Views - Last Post: 07 June 2012 - 05:38 AM Rate Topic: -----

#1 zee5229  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-March 12

move output cursor back to top of screen

Posted 06 June 2012 - 01:21 PM

I am trying to print a series of symbols across the screen. the only problem is the symbols print out horizontally instead of vertically. I think I need to move the cursor back up to the first line after every symbol. If anyone can tell me how to do this or tell me a more efficient way to receive that same result, that would be very helpfull. If I didn't do a good enough job of explaining myself,I usually don't, just run my code and it will become clear. Thanks any and everyone for the help.

import java.awt.*;
import java.io.*;
import java.util.*;
public class Big_Numbers
{
	public static void main(String zee[])throws IOException
	{
		//Scanner input=new Scanner(new File("numbers.in"));
		//String bigNumber=input.nextLine();
		String bigNumber="142";

		int length=bigNumber.length();

		String numbers[]=new String[length];

		for(int i=0; i<length;i++ )
		{
			numbers[i]=bigNumber.substring(i, i+1);

			switch (numbers[i])
			{

				case "1": one();
					break;
				case "2": two();
					break;
				case "3": three();
					break;
				case "4": four();
					break;
				case "5": five();
					break;
				case "6": six();
					break;
				case "7": seven();
					break;
				case "8": eight();
					break;
				case "9": nine();
					break;
				case "0": zero();
				default: System.out.print("error: not a number");
					break;
			}//end of switch case

		}//end of for loop




	}//end of main method


     static void one()
     {
       System.out.println("   1");
       System.out.println("  11");
       System.out.println("   1");
       System.out.println("   1");
       System.out.println(" 11111");
     }

      static void two()
     {
     	System.out.println("22222");
     	System.out.println("    2");
     	System.out.println("22222");
     	System.out.println("2");
     	System.out.println("22222");
     }

      static void three()
     {
     	System.out.println("33333");
     	System.out.println("    3");
     	System.out.println("  333");
     	System.out.println("    3");
     	System.out.println("33333");
     }

     static void four()
     {
     	System.out.println("4   4");
     	System.out.println("4   4");
     	System.out.println("44444");
     	System.out.println("    4");
     	System.out.println("    4");
     }

     static void five()
     {
     	System.out.println("55555");
     	System.out.println("5");
     	System.out.println("55555");
     	System.out.println("    5");
     	System.out.println("55555");
     }

     static void six()
     {
     	System.out.println("66666");
     	System.out.println("6");
     	System.out.println("66666");
     	System.out.println("6   6");
     	System.out.println("66666");
     }

     static void seven()
     {
     	System.out.println("77777");
     	System.out.println("    7");
     	System.out.println("    7");
     	System.out.println("    7");
     	System.out.println("    7");
     }

     static void eight()
     {
     	System.out.println("88888");
     	System.out.println("8   8");
     	System.out.println("88888");
     	System.out.println("8   8");
     	System.out.println("88888");
     }

     static void nine()
     {
     	System.out.println("99999");
     	System.out.println("9   9");
     	System.out.println("99999");
     	System.out.println("    9");
     	System.out.println("99999");
     }

     static void zero()
     {
     	System.out.println("00000");
     	System.out.println("0   0");
     	System.out.println("0   0");
     	System.out.println("0   0");
     	System.out.println("00000");
     }



Is This A Good Question/Topic? 0
  • +

Replies To: move output cursor back to top of screen

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: move output cursor back to top of screen

Posted 06 June 2012 - 01:24 PM

You just can't on Windows
On Unix/Linux there are the Curse functions
On OpenVMS the <esc> VT220 sequences
Was This Post Helpful? 0
  • +
  • -

#3 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2556
  • View blog
  • Posts: 10,664
  • Joined: 20-September 08

Re: move output cursor back to top of screen

Posted 07 June 2012 - 05:38 AM

See THIS
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1