Welcome to Dream.In.Code
Become a Java Expert!

Join 149,384 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,355 people online right now. Registration is fast and FREE... Join Now!




Formatting Arrays

 
Reply to this topicStart new topic

Formatting Arrays, Formatting Arrays

Jdiggz
24 Apr, 2007 - 05:01 PM
Post #1

New D.I.C Head
*

Joined: 24 Apr, 2007
Posts: 1


My Contributions
I need to format my output. It looks like this.
1-9 |
10-19 |
20-29 |
30-39 |
40-49 |
50-59 |
60-69 |
70-79 |
80-89 |
90-100 |

I need all of the lines to match up so they are not all off center. This is my program.

package Justin_CSIS;
import java.util.Scanner;
public class Astract {

public static void main(String[] args) {

Scanner keyboard = new Scanner(System.in);
int [] stars = new int[10];
int[] row = { 1, 9, 10, 19, 20, 29, 30, 39, 40, 49,
50, 59, 60, 69, 70, 79, 80, 89, 90, 100};
int input,
x;

do
{
System.out.println("Please enter number 1 through 100"
+ " with no decimals." + " Enter 0 to quit.");
input = keyboard.nextInt();
x = input/10;


}while(input !=0);

for(int index = 0; index < 19; index++)

{

System.out.println(row[index] + "-" + row[index + 1] + " |");
}
}
}
User is offlineProfile CardPM
+Quote Post

vasdueva
RE: Formatting Arrays
24 Apr, 2007 - 05:41 PM
Post #2

D.I.C Head
**

Joined: 3 Apr, 2007
Posts: 69


My Contributions
You can use the tab command. \t

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:46AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month